[V4MD] question about string vars
Ruslan Zasukhin
ruslan_zasukhin at valentina-db.com
Sat Oct 30 05:19:25 CDT 2010
> Evan Ritchie (Sat, 30 Oct 2010, 01:47AM):
> Thanks for your input and advice. All is working quite well.
>
> One more quick question:
>
> User input searches that includes the use of a variable within an SQL query
> ie....
>
> ---------------
> SearchText = "'%" & "Tony" & "%'"
>
> -- put SearchText
>
> res = gDB.SqlQuery( "SELECT T_CATALOG.TITLE, T_CATALOG.ARTIST,
> T_CATALOG.DOCPATHNAME, T_CATALOG.PAGES_ FROM T_CATALOG WHERE ARTIST LIKE
> string(SearchText) FOR XML AUTO ELEMENT ")
> -------------
>
> This does not work. What will if using variables/ stings within an SQL query.
>
> I am looking through your documentation but not seeing the answer just yet.
>
> Thanks.
ruslan (Sat, 30 Oct 2010, 10:16AM):
of course this not works. you have 2 ways
1) simple -- use string concat
query = ""SELECT T_CATALOG.TITLE, T_CATALOG.ARTIST, T_CATALOG.DOCPATHNAME,
T_CATALOG.PAGES_ FROM T_CATALOG WHERE ARTIST LIKE '" & SearchText & "' FOR
XML AUTO"
2) use SQL binding feature of Valentina -- best way on many aspects
res = gDB.SqlQuery( "SELECT T_CATALOG.TITLE, T_CATALOG.ARTIST,
T_CATALOG.DOCPATHNAME, T_CATALOG.PAGES_ FROM T_CATALOG WHERE ARTIST LIKE :1
FOR XML AUTO ELEMENT", [ SearchText ] )
--
Best regards,
Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc
Valentina - Joining Worlds of Information
http://www.paradigmasoft.com
[I feel the need: the need for speed]
More information about the Valentina
mailing list