Andromo - Start Making Apps - Free Signup

Announcement

Collapse
No announcement yet.

SQLite.Query action

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQLite.Query action

    Does the SQLite.Query action accept variables as input?

    I am trying to put the action in a "for" loop, where several variables change each time through.

    Using the Online Help as a guide, I inserted these lines:

    (before the "for" loop)

    db = SQLite.Open(dbname);

    SQLite.Query(db,"create table Users(userid integer primary key, LastName text, FirstName text, Age integer)");

    (inside the "for" loop )

    SQLite.Query(db,"insert into Users values(1,'Sellers','Ted',48)");

    and tried using variables in place of the "1" "'Sellers'" etc. I tried various ways of doing it, but so far no luck. I know the variables are valid, for example using "count" for the number, and my_table.value as a string variable. And it works fine using regular numbers and text. Maybe I don't have the syntax down pat yet? I thank you in advance for any help you can offer.

  • #2
    Code:
    for n=1, 10 do
    x = n + 100;
    SQLite.Query(db,"insert into Users values("..n..",'Sellers','Ted',"..x..);
    end

    Comment


    • #3
      As Worm pointed out, the actual query send to the DB is a string and as with any string within AMS you need to concatenate the variable into the string to have it function correctly. Just remember to properly quote text components within your query.

      Code:
      for n=1, 10 do
      x = n + 100;
      strlastname = "Sellers"..x
      strfirstname = "Ted"..x  --added the X for uniqueness :D
      SQLite.Query(db,"insert into Users values("..n..",\""..strlastname.."\",\""..strfirstname.."\","..x..);
      end
      Tigg
      TJ-Tigger
      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
      "Draco dormiens nunquam titillandus."
      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

      Comment


      • #4
        Kinda wordy aren't ya Tig?

        Didn't even realize that I didn't explain why. Thanks for having my back :yes

        Comment


        • #5
          Originally posted by Worm
          Kinda wordy aren't ya Tig?

          Didn't even realize that I didn't explain why. Thanks for having my back :yes
          yeah I can get that way some times. Just depends on the day of the week and the time of the day and if I have had too much caffeine in the morning. Yeah if I have had too much of that caffeine then I tend to ramble on and on and on and on until the caffeine wears out and . . . oh I did it again.

          TJ-Tigger
          "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
          "Draco dormiens nunquam titillandus."
          Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

          Comment


          • #6
            :yes :yes

            Comment


            • #7
              Thanks, I figured maybe it was me concatenating incorrectly... I've done it before.
              I guess I'm still discovering the many joys of concatenation. pj

              Comment

              Working...
              X