M.J.
M.J.

Reputation: 16646

how to create a string in DB2

i want to craete a string which contains ' character, but whenever i try it fails.

SET STR_BUFF = 'SELECT * FROM' || VAR_TABLE || ' WHERE NAME LIKE '%abc%';

But the procedure doesn't compile. Does DB2 also has some characters like Java where we represent " like \".

Thanks,

Upvotes: 0

Views: 711

Answers (1)

niktrs
niktrs

Reputation: 10066

Use two single quotes to escape the quote character

SET STR_BUFF = 'SELECT * FROM' || VAR_TABLE || ' WHERE NAME LIKE ''%abc%'';' 

Upvotes: 3

Related Questions