Apostrophe and UPDATE

Peter Haworth pete at lcsql.com
Wed Oct 9 10:09:01 EDT 2013


Don't need to escape anything when using the :1,:2,etc notation, but if you
did, it would be ''' not \'.

The update syntax is UPDATE tablename SET colname=:1 etc

Pete
lcSQL Software
On Oct 9, 2013 3:55 AM, "Paul Foraker" <paul.foraker at gmail.com> wrote:

> Stephen,  escaping the single quote with another quote causes the same
> error, with the result showing \'\' instead of \'.  I tried it with and
> without variable substitution.
>
> Monte, my UPDATE syntax was incorrect. Thanks!
>
> In case anyone else needs something like this, here's the code that worked:
>
> <code>
> on testWrap
>    put the fldNames of this cd into tFldNames
>    delete item 1 of tFldNames -- contact_id
>    put getSQLWrappers("contact",tFldNames) into temp
>    answer temp
> end testWrap
>
> function getSQLwrappers pTableName, pFldNames
>    -- takes a list of field names and returns them wrapped for SQL
>    -- removes "_" in fld names, prepends "t" and uses CamelCase
>    -- so "last_name" becomes tLastName
>    put "UPDATE" && pTableName && "SET " into tSQL
>    repeat for each item thisOne in pFldNames
>       put thisOne &&"= '" & varNameFromFldName(thisOne) & "', " after tSQL
>    end repeat
>    delete last char of tSQL -- remove last chars
>    delete last char of tSQL
>    put " WHERE id = '" &tID &"'" after tSQL
>    return tSQL
> end getSQLwrappers
>
> function varNameFromFldName pFldName
>    set itemDelimiter to "_"
>    put "t" into varName
>    repeat for each item thisOne in pFldName
>       put toUpper(char 1 of thisOne) into char 1 of thisOne
>       put thisOne after varName
>    end repeat
>    return varName
> end varNameFromFldName
> </code>
>
> -- Paul
> _______________________________________________
> 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