How to escape two single quotes in DB2?

前端 未结 2 990
孤街浪徒
孤街浪徒 2021-01-27 07:55

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

相关标签:
2条回答
  • 2021-01-27 08:22

    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.

    0 讨论(0)
  • 2021-01-27 08:23

    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'
    
    0 讨论(0)
提交回复
热议问题