Records with ,s and returns

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
egolombek
Posts: 74
Joined: Thu Jan 30, 2020 2:11 pm

Records with ,s and returns

Post by egolombek » Fri Apr 03, 2020 1:37 pm

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

cpuandnet
Posts: 32
Joined: Thu Jan 17, 2019 6:43 am

Re: Records with ,s and returns

Post by cpuandnet » Fri Apr 03, 2020 5:58 pm

Change your update SQL statement to

Code: Select all

put "UPDATE students SET name = :1, class = :2, group1 = :3, group2 = :4 WHERE id="&stID into scrpt
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 = :5" into scrpt
revExecuteSQL connectID, scrpt,"stName","stClass","stGroup1","stGroup2", "stID"

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Records with ,s and returns

Post by Klaus » Fri Apr 03, 2020 6:46 pm


egolombek
Posts: 74
Joined: Thu Jan 30, 2020 2:11 pm

Re: Records with ,s and returns

Post by egolombek » Sat Apr 04, 2020 8:09 pm

That works! Thank you!!! Eric

Post Reply

Return to “Databases”