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

How do you escape the quote in the SQL query??

Status
Not open for further replies.

fletchsod

Programmer
Dec 16, 2002
181
How do you guys deal with quotes in SQL Query for DB2??

When I use this query..

--snip--
INSERT INTO CUSTOMERS1 ( CSTM_COMPANY_NAME )
VALUES ('Baltimore\'s Collections')
--snip--

I get the

--snip--
SQL0010N The string constant beginning with "', '')" does not have an ending string delimiter. SQLSTATE=42603
--snip--

error. So, how do you guys do the escape the quote query for single quote and double quote??

Thanks...
 
Hi Fletchsod,

You need to use a '' in place of the apostrophe in your text string - (2 Single quotes)

INSERT INTO CUSTOMERS1 ( CSTM_COMPANY_NAME )
VALUES ('Baltimore''s Collections')

Not sure what the \ was doing - or whether you wanted it still there.

Hope this helps
 
Great, that seem to work...

As for the \ part, well, I did without it at first which doesn't work. So, I added the \ part to escape the single quote to see if it work but that doesn't work either. I can take that out and use the two single quotes instead...

Thanks...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top