I have the following problem. Can anybody advice me?
I need to create and maintain sqlite databases for my applications. Creating the DB and the tables goes just fine.
The following line of code does what it should:
put "INSERT into sticky_table VALUES (1235,1235,'200,456',90,70,'120,90,30','green','this is a message');" after tSQL
but the one below does nothing:
put "INSERT into sticky_table VALUES (1234,gShortID,'123,456',90,70,'yellow','black','this is a message');" into tSQL
that is, if I have variable names in the insert statement, they don't get evaluated, even though the variables have
values; that I have verified with the message box.
What am I missing?
The total environment for the insert looks like this:
on databaseInsertSticky
## Insert names and email addresses into the database
local tDatabaseID,tSQL
put getDatabaseID() into tDatabaseID
show message box
put gShortID into message
put "INSERT into sticky_table VALUES (1234,gShortID,'123,456',90,70,'yellow','black','Lorem ipsum');" into tSQL
revExecuteSQL tDatabaseID, tSQL
end databaseInsertSticky
which, as I indicated, works fine for specific constant values, but not for variables.
SQL does not evaluate variables
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: SQL does not evaluate variables
Hi ptatray,
Do you see that you have your variable gShortID inside quotation marks, makes it a string.
Try this
Simon
Edit; Oh and Welcome to the forum.
Do you see that you have your variable gShortID inside quotation marks, makes it a string.
Try this
Code: Select all
put "INSERT into sticky_table VALUES (1234," & gShortID & ",'123,456',90,70,'yellow','black','this is a message');" into tSQL
Edit; Oh and Welcome to the forum.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: SQL does not evaluate variables
Hi ptatray,
1. welcome to the forum!
2. You are passing the STRING "gShortID" and not its content!
Do as Simon, who beats me by a minute or two, says!
Best
Klaus
1. welcome to the forum!
2. You are passing the STRING "gShortID" and not its content!
Do as Simon, who beats me by a minute or two, says!
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: SQL does not evaluate variables
That is a first!
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!