vexing MySQL query problem

Peter Haworth pete at lcsql.com
Fri Jan 25 16:55:44 EST 2013


Hi Sieg,
What error are you getting?

The problem may be that "text" is not only an LC keyword, it's also an SQL
keyword.  I find it's useful to always include table and column names in
double quotes in SQL commands.

Pete
lcSQL Software <http://www.lcsql.com>


On Fri, Jan 25, 2013 at 1:20 PM, Sieg Lindstrom <sl at trackandfieldnews.com>wrote:

> I am working on an app to update a MySQL database table. Unfortunately,
> one of the fields in the table is named "Text" and I can't change that
> because it's a long-extant table which other non-LC scripts query. I am
> able to update the table except when the "Text" field is part of the query.
>
> Hence this query won't work.
>
> do "revExecuteSQL myDB," & quote & "INSERT INTO RelevantTable (Text) " &
> "VALUES ('" & thisText  & "')" & quote
>
> But this query does work.
>
> do "revExecuteSQL myDB," & quote & "INSERT INTO RelevantTable (URL) " &
> "VALUES ('" & thisURL  & "')" & quote
>
> It works even though URL is a LiveCode keyword. "Text" is a keyword but
> it's also a property. I guess that is the rub?
>
> Of course, with MySQL I have the option of inserting values into the table
> without identifying the fields by name. The catch seems to be that using
> that approach I have to insert values into all the fields, including the
> nullable and auto-incrementing fields. As I understand it, the value null
> should be inserted into the auto-incrementing fields. Hence I've tried the
> following query.
>
> do "revExecuteSQL headlinesDB," & quote & "INSERT INTO RelevantTable
> VALUES (null, '" & thisURL & "', null, '" & thisText & "', null)" & quote
>
> This doesn't work either. Is this because "null" is a LC constant? If so,
> is there some way I can escape it in the query? Or some other, better way
> to phrase the query?
>
> Thanks in advance,
>
> Sieg Lindstrom
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list