How to escape two single quotes in DB2?

二次信任 提交于 2019-12-25 11:56:54

问题


E.g: Code=''. If I use Code ='''', in the result I'm getting only one quote.


回答1:


Keep the current start and end quotes. Then double each quote supposed to be a part of the string value.

Code = ''''''

Or you can perhaps use a Unicode string literal:

Code = U&'\0027\0027'



回答2:


More information in your qustion would be helpful. Which OS or where exactly you execute it. Here is a working example from a Db2 command line:

db2 create table str(text varchar(20))
DB20000I  The SQL command completed successfully.

db2 "insert into str values '''''' "
DB20000I  The SQL command completed successfully.

db2 select * from str

TEXT
--------------------
''

1 record(s) selected.

Note the double quotes round the SQL to avoid shell interactions/reactions.



来源:https://stackoverflow.com/questions/46240066/how-to-escape-two-single-quotes-in-db2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!