Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Single quote in search string.
Problem is sloved if you use bind variables
I think in access you can do:
strTarget = "'I can''t go on!"
strSQL = "SELECT * FROM MY_TABLE WHERE MYFIELD = ?strTarget"
At least you can in VFP and not many people know this. This emulates bind variables.
Also I don't know if in PL\QL you can do somthing like:
strTarget = ''''||'I can'||''''||''''||'t go on!'
This is because:
''''='
Hope that helps...
In article <janP4.4439$J81.35501_at_newsr1.maine.rr.com>,
"Robert Wagner" <RobertWagner_at_alum.mit.edu> wrote:
> If I want do search for a single quote, is the only option to double
the
> single quote?
>
> In other words is constructing the SQL statement like this the only
way to
> handle the problem?:
> strTarget = "'I can''t go on!"
> strSQL = "SELECT * FROM MY_TABLE WHERE MYFIELD = ' " & strTarget &
"'"
> (I'm using Access to construct strSQL, and the last is
> double-single-double quotes.)
>
> (I'm using doublequotes to delineate the string, since I'm working in
> Access, using ADO against an Oracle backend.)
>
> It could get messy if there are TWO or MORE single quotes in the
search
> item.
>
> It'd be nice if we could have the option of defining a '' (two single
> quotes) as the delimiter, similarly to the way it's done in Access
(where
> double quotes are used as the delimiter. There, the string would look
like:
> strTarget = "'I can't go on!"
> strSQL = "SELECT * FROM MY_TABLE WHERE MYFIELD = """ & strTarget &
""""
> (In the last line, all quotes are double-quotes.)
> This last looks worse, but it's actually better, since I don't have to
> 'customize' the target string.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed May 03 2000 - 00:00:00 CDT
![]() |
![]() |