Handling Quoted Strings in DB2

greenspun.com : LUSENET : DBAzine : One Thread

I want to insert quoted string as data

ex: insert into myquery (id,desc) values(100,'select * from car where manufacturer='BMW' ')

I will use the desc and query the DB again. I am able to do this in Oracle and MS SQL

can anyone tell me how to do this in DB2(I m using V 7.2)

Thanx in advance

Swami

-- Swaminathan (svelmurugan@selectica.com), April 17, 2002

Answers

When you have a string like that you need to use two single quotes. Two consecutive string delimiters are used to represent one string delimiter within the character string. Try to write the SQL using

insert into myquery (id,desc) values(100,'select * from car where manufacturer=''BMW'' ')

-- Craig S. Mullins (Craig_Mullins@BMC.com), April 19, 2002.


Moderation questions? read the FAQ