SQL Update

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

SQL Update

Post by warrenk » Fri May 01, 2009 7:08 pm

I am having a issue with a SQL Update when my variable has a single quote in the data.

ie. tDescriptionReview = It's a fascinating book

...the single quote in "It's" is causing my update to fail since I am using single quotes to surround by text fields. How would I get around this?

Here is how I am updating...

put "UPDATE books set description = " & "'" & tDescriptionReview & "'" & " where id = " & tID into tSQL
revexecutesql gConID, tSQL

Thanks!
Warren

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri May 01, 2009 7:44 pm

Hi Warren,

Use the backslash to escape the single quote. You don't say which SQL flavour you use, but in the MySQL documentation, you'll find more information about escaping characters.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Post by warrenk » Sat May 02, 2009 3:15 pm

Thanks Mark...the backslash worked!

Warren

Post Reply