I am very new to SQL and databases, so I apologize for what is probably an obvious question.
I am using data that includes commas and returns. This seems to be a problem when building SQL Queries. I discovered that I could solve this problem when I insert a record by using :s as follows:
put "INSERT INTO students (name,class,group1,group2) VALUES (:1,:2,:3,:4)" into scrpt
revExecuteSQL connectID, scrpt,"stName","stClass","stGroup1","stGroup2"
But, I cannot figure out how to do the equivalent with updating. The following does not work:
put "UPDATE students SET (name,class,group1,group2) VALUES (:1,:2,:3,:4) WHERE id="&stID into scrpt
revExecuteSQL connectID, scrpt,"stName","stClass","stGroup1","stGroup2"
Any help would be most appreciated!!! (And if there is a better reference than the LiveCode lessons which are so basic, I'd really appreciate a link)
Thanks! Eric
Records with ,s and returns
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Records with ,s and returns
Change your update SQL statement to
I would also go a step further and also put the stID into the placeholders for clarity and consistency
Code: Select all
put "UPDATE students SET name = :1, class = :2, group1 = :3, group2 = :4 WHERE id="&stID into scrpt
Code: Select all
put "UPDATE students SET name = :1, class = :2, group1 = :3, group2 = :4 WHERE id = :5" into scrpt
revExecuteSQL connectID, scrpt,"stName","stClass","stGroup1","stGroup2", "stID"
Re: Records with ,s and returns
That works! Thank you!!! Eric