[英]Oracle Regex Replace on String Query
Query to fetches the sub xml from an xml saved in the CLOB column of my table is given as : 从保存在我的表的CLOB列中的xml中提取子xml的查询为:
select REGEXP_REPLACE(xmltype(t.prov_request).extract('//SOAP_Domain_Msg/Body').getStringVal(),'<Body>|</Body>','') xml
from tbl_prov_comptel
There is "SO1_USERNAME" value="xxx"
in the string returned by the above query. 以上查询返回的字符串中有
"SO1_USERNAME" value="xxx"
。 What i want to achieve is to form a consolidated query and append something in the start of the expression above. 我要实现的是形成一个合并的查询,并在上面的表达式的开头添加一些内容。
ie. 即。
"SO1_USERNAME" value="qwexxx"
Oracle Setup : Oracle安装程序 :
CREATE TABLE tbl_prov_comptl ( prov_request CLOB );
INSERT INTO tbl_prov_comptl VALUES (
'<SOAP_Domain_Msg><Body><NS4:ModifyRequest xmlns:NS4="http://soa.comptel.com/2011/02/instantlink"><NS4:RequestParameters> <NS4:Parameter name="SO1_USERNAME" value="222671150"/></NS4:RequestParameters> </NS4:ModifyRequest></Body></SOAP_Domain_Msg>'
);
Query : 查询 :
SELECT EXTRACTVALUE(
xml,
'//NS4:ModifyRequest/NS4:RequestParameters/NS4:Parameter[name="SO1_USERNAME"]/@value',
'xmlns:NS4="http://soa.comptel.com/2011/02/instantlink"'
) AS SO1_USERNAME,
x.xml.getStringVal() AS xml
FROM (
SELECT XMLType( prov_request ).extract( '//SOAP_Domain_Msg/Body/*' ) AS xml
FROM tbl_prov_comptl
) x;
Output : 输出 :
SO1_USERNAME XML
------------ ------------------------------------------------------------------------------
222671150 <NS4:ModifyRequest xmlns:NS4="http://soa.comptel.com/2011/02/instantlink"><NS4
:RequestParameters> <NS4:Parameter name="SO1_USERNAME" value="222671150"/></NS
4:RequestParameters> </NS4:ModifyRequest>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.