zoukankan      html  css  js  c++  java
  • oracle中单引号的处理

       当想让输出的结果中字段带有单引号',

    场景一:连续三个单引号'''

     select '''helin''' from dual;
            ---'helin'

    场景二:拼接字段的结果集--连续4个单引号

    select 'update ct_cust_info set cust_name =',
           '''' || a.cust_name || '''',
           'cust_address = ',
           '''' || a.cust_address || '''',
           'where cust_id = ',
           '''' || a.cust_id || ''''
      from (select cust_id, cust_name, CUST_ADDRESS
              from ct_cust_info_crm
            minus
            select cust_id, cust_name, CUST_ADDRESS from ct_cust_info_billing1) a
    --1    update ct_cust_info set cust_name =    '++SFVBIEJJTkc='    cust_address =     '++TEVWRUwgMzUsIDI1IENBTkFEQSBTUVVBUkUsIENBTkFSWSBXSEFSRiwgTE9ORE9OLCBFMTQgNUxR'    where cust_id =     '100321000000002243'
    --2    update ct_cust_info set cust_name =    '++RE9ORyBIQU8='    cust_address =     '++TEVWRUwgMzUsIDI1IENBTkFEQSBTUVVBUkUsIENBTkFSWSBXSEFSRiwgTE9ORE9OLCBFMTQgNUxR'    where cust_id =     '100321000000002258'
     

    场景三:和场景2一致,另一种写法:q'/string/'  中间的string表示任何字符

    select 
    'update ct_cust_info set cust_name =',
    q'/'/'|| a.cust_name ||q'/',/',
    'cust_address = ',
    q'/'/'|| a.cust_address ||q'/'/',
    'where cust_id = ',
    q'/'/'|| a.cust_id ||q'/';/'
    from 
    (select cust_id,cust_name,CUST_ADDRESS  from ct_cust_info_crm
    minus
    select cust_id,cust_name,CUST_ADDRESS  from ct_cust_info_billing1) a
  • 相关阅读:
    第八周作业
    第七周作业
    第六周作业
    第五周作业
    2019第四周作业
    第二周基础作业
    秋季学期学习总结
    人生路上对你影响最大的三位老师
    IDF实验室-简单编程-特殊的日子 writeup
    IDF实验室-简单的ELF逆向 writeup
  • 原文地址:https://www.cnblogs.com/whut-helin/p/7928374.html
Copyright © 2011-2022 走看看