Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: problem with a SQL select request
In article <2001829-161345-257116_at_foorum.com>, manu says...
>
>
>Hi,
>
>I know it's a common problem, but I'd like to know if it exists a more simple
>solution ...
>
>in the following request :
>"SELECT LASTNAME FROM CONTACTS
>WHERE (((CONTACTS.LASTNAME) = ' " + name + " ') "
>
>if name = "N'Guyen" for exemple, an error is generated because of the orthograph
>of the word "name" .... it contains the character '
>
the answer is to use a bind variable -- it is the right answer for a couple of reasons.
select lastname from contact where lastname = ?
and BIND the value N'Guyen as a host variable
It will not only avoid this quoting issue alltogether -- it'll make the overall performance of your system better (significantly less hard parses, less contention for the library cache, better memory utilization and so on)
>Does it exist with Oracle a way to ignore or replace this character, or must I
>read every string and double the character to make Oracle accept to execute my
>SQL command ??
>
>I hope somebody will understand my question in spite of my ridiculous English
>
>Thank you in advance
>
>
>------
>User of http://www.foorum.com/. The best tools for usenet searching.
-- Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Wed Aug 29 2001 - 13:56:38 CDT