Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

apostrophe mark or single quote

Status
Not open for further replies.

crsdev

Programmer
Sep 29, 2006
96
US
Hello Friends:
what do I do in this situation:

for a where clause

select *
from XXXX x
where x.name= ' john's '

how can i say that it's a apostrophe mark and not a single quotes, so that i don't get an error message.

Thanks.
 
Try it this way:
Code:
select *
from XXXX x
where x.name= ' john''s '
or better use bind variables.
 
thanks stefanhei,
can you please elaborate a little on blind variables.
I am using name as a variable and most of them don't have apostrophe, only a couble

 
CRSDev,

Unfortunately, with all the "single-quote" work-arounds of which I am aware (including using bind variables), the "cure" is as bad as (if not worse than) the "disease". If you have "only a couple" of cases where you are comparing a value that contains a single quote, and you are doing the comparison with manually entered literals (as it appears that you are), then the method that Stefan proposed is generally the least cumbersome.

If the problem surrounds end-users having to enter the value, then we can pursue other avenues, including bind variables.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Thanks Mufasa,
yes the problem does surround end-user having to enter the value.
what other avenues are there..
 
What software does the end-user use to enter the values (e.g., SQL*Plus, third-party GUI, scripts, et cetera)?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Mufasa, They use Business Objects. they basically select from a drop down list.
 
If they are using Business Objects, then how are they creating code that looks like your example:
Code:
select *
from XXXX x
where x.name= ' john''s '
Specifically, what item from a drop down list would look like, " ' john''s ' "?

I'm not trying to be dense or difficult...I'm just wanting to clearly understand your context so that I can suggest a solution that will best meet your need.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
this is the code i use

select id
from some_table a
where a.name='{?NAME}'

the name part is picked by the user from a drop down list.
THanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top