Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to use a ' in dynamic SQL statement
'SELECT * FROM table WHERE column = ''Y'' ... '; so escape the character by
itself should work.
Hth,
Sybrand Bakker, Oracle DBA
Jason Morris <morrisj_at_cableregina.com> wrote in message
news:otWn4.207$EM31.4391005_at_tomcat.sk.sympatico.ca...
> Hi all, hope there is an easier way to do this.
>
> I'm using dynamic SQL in a stored procedure, and would like to do
something
> like this:
>
> sqlString := 'SELECT * FROM table WHERE column = 'Y' ... ';
>
> Now the "column='Y'" causes problems, because it thinks they're string
> terminators. Is there an escape character or something similar? In SQL
Server
> it was just " column=''Y'' ".
>
> Right now I'm stuck doing:
> column = ' || chr(39) || 'Y' || chr(39) || ' .... '
> but this strikes me as ugly, and there should be a better way (I'd like to
> think).
>
> Comments? (And yes, I must use dynamic SQL, it's not an option)
>
> Thanks for any help
> Jason Morris
> morrisj_at_cableregina.com
>
Received on Tue Feb 08 2000 - 09:55:10 CST
![]() |
![]() |