我想替换两个字符中断之间的信息“|”
列
中的数据Parameters_Sent_To_Procdure|Information_to_replace_|Put_the_existing_information_back
所以我想把现有参数重新替换为两个 Pipes“|”之间的信息,然后将信息放回第二个管道之后
答案 0 :(得分:2)
我想替换两个字符中断之间的信息" |"
最简单的方法是提取子字符串,连接它与您想要替换期望值 >使用以下然后连接所有内容:
SQL> WITH DATA AS 2 (SELECT 'Parameters_Sent_To_Procdure|Information_to_replace_|Put_the_existing_information_back' str 3 FROM dual 4 ) 5 SELECT SUBSTR(str, 1, instr(str, '|', 1,1) -1) 6 || '' 7 || SUBSTR(str, instr(str, '|', 1, 1) + 1, 8 instr(str, '|', 1, 2) - 9 instr(str, '|', 1, 1) -1) AS "new_str" 10 FROM data; new_str -------------------------------------------------------------------------------------------- Parameters_Sent_To_ProcdureInformation_to_replace_
查询的工作原理:
SELECT SUBSTR(str, 1, instr(str, '|', 1,1) -1)
上述SUBSTR提取字符串的第一部分,即从字符串的开头到|
的第一次出现。
'<Here goes the string you want to replace>'
以上应该是你的新价值。
SUBSTR(str, instr(str, '|', 1, 1) + 1,
instr(str, '|', 1, 2) -
instr(str, '|', 1, 1) -1)
上面的SUBSTR提取字符串的最后一部分,即从|
的第二次出现到字符串的结尾。