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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting a string with an apostrophe

Status
Not open for further replies.

SJSFoxPro

Technical User
Jun 19, 2003
110
US
I've been asked to update a varchar2 field in a record to the following string:
0: NO MATCH WAS RUN, FOR 1994 AND LATER CASES;1: LAST NAME AND MAIDEN NAME;2: LAST NAME, DIDN'T CHECK MAIDEN NAME (OR MALE);3: LAST NAME, MISSING MAIDEN NAME;4: LAST NAME, MAID

Can anyone help me with the syntax to insert this string? I'm having trouble with the apostrophe in the word "DIDN'T". I've tried using double quotes around the apostrophe and using || to concatenate, but I still get an "invalid identifier" error.
 
Use 2 single quotes for the single quote you require:

[tt]... LAST NAME, DIDN''T CHECK ...[/tt]
 
SJS,

If you don`t like the hoops you need to jump through to get an apostrophe into your string, then you can do as I did here without your knowing it...I used a backward apostrophe above in the word "don`t" and I'll bet you didn't notice it. If that is a satisfactory solution, then your code would look like this:
Code:
col a heading "Your string using backward apostrophe" format a60
select '0: NO MATCH WAS RUN, FOR 1994 AND LATER CASES;'||
       '1: LAST NAME AND MAIDEN NAME;'||
       '2: LAST NAME, DIDN`T CHECK MAIDEN NAME (OR MALE);'||
       '3: LAST NAME, MISSING MAIDEN NAME;'||
       '4: LAST NAME, MAID...' a
from dual;

Your string using backward apostrophe
------------------------------------------------------------
0: NO MATCH WAS RUN, FOR 1994 AND LATER CASES;1: LAST NAME A
ND MAIDEN NAME;2: LAST NAME, DIDN`T CHECK MAIDEN NAME (OR MA
LE);3: LAST NAME, MISSING MAIDEN NAME;4: LAST NAME, MAID...


1 row selected.
Let us know if that trick works for you.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)

Do you use Oracle and live or work in Utah, USA?
Then click here to join Utah Oracle Users Group on Tek-Tips.
 
Thank you both. I knew it was a simple solution, but pressed for time I couldn't seem to locate the information quickly in any of my references. (I need a better SQL reference!)

Thanks to Santa Mufasa for the clever alternative to avoid the issue altogether!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top