有一个字符串如下:
"select f1 Code, f2 Value from tb1 where f3 = 'Code'"

"select f1 CODE, f2 Value from tb1 where f3 = 'Code'"

"select f1 Code, f2 VALUE from tb1 where f3 = 'Code'"

"select f1 CODE , f2 VALUE from tb1 where f3 = 'Code'"

"select f1 Code, f2 Value from tb1 where f3 = 'Code' order by VALUE "
凡此种种,想统一替换成"select f1 编码 , f2 名称 from tb1 where f3 = 'Code'"

"select f1 编码, f2 名称 from tb1 where f3 = 'Code' order by 名称 "

解决方案 »

  1.   

    假设串是S
    replace(upper(S),'被替换值','目标值')如果你有多个替换,估计要嵌套了.
      

  2.   

    oracle里好像不区分大小写的
    这几个SQL在我看来都是一样的啊
      

  3.   

    我的替换不能替换"f3 = 'Code'"中的Code
      

  4.   

    1楼的正解
    但是看楼主的意思最后好像还是想要小写
    最好是
    replace(lower(S),'code','编码')
      

  5.   

    1楼的会把原来的串替换成
    "select f1 编码 , f2 名称 from tb1 where f3 = '编码'"

    "select f1 编码, f2 名称 from tb1 where f3 = '编码' order by 名称 " 
    而我要的是
    "select f1 编码 , f2 名称 from tb1 where f3 = 'Code'"

    "select f1 编码, f2 名称 from tb1 where f3 = 'Code' order by 名称 " 
    单引号内的Code或code或codexxxx是不替换de
      

  6.   

    replace(lower(S),' code','编码')
    ' code'  前面加上个空格' '
      

  7.   

    那也把f3 = 'Code'换成f3='code'了,还是不满足要求
      

  8.   

    大小写问题解决了,那就只剩下匹配模式的问题.
    加空格不行,可以试试加code后面加','
    不管怎么说,这是字串本身的问题,你总要找到替换和不替换的字串之间的区别才能做,
    找到了,转换成代码就行了,找不到,怎么也没用.
      

  9.   

    先替换 'Code' 为 zzz, 再替换 名称、编码,再把zzz替换为'Code'