Anda dapat mengekstrak konten simpul dengan XMLQUERY
:
select xmlquery('declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
declare namespace urn = "urn:ABC";
/soapenv:Envelope/soapenv:Body/urn:settleResponse/settleReturn/message/text()'
passing XMLType(message)
returning content) as message,
xmlquery('declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
declare namespace urn = "urn:ABC";
/soapenv:Envelope/soapenv:Body/urn:settleResponse/settleReturn/errorCode/text()'
passing XMLType(message)
returning content) as errorCode,
xmlquery('declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
declare namespace urn = "urn:ABC";
/soapenv:Envelope/soapenv:Body/urn:settleResponse/settleReturn/status/text()'
passing XMLType(message)
returning content) as status
from external;
MESSAGE ERRORCODE STATUS
-------------------- -------------------- ----------
Missing first name INVALID_ACC Failed
Atau mungkin lebih sederhana, terutama jika Anda memiliki banyak pesan untuk ditangani, dengan XMLTABLE
:
select x.*
from external ext
cross join xmltable(
xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
'urn:ABC' as "urn"),
'/soapenv:Envelope/soapenv:Body/urn:settleResponse/settleReturn'
passing XMLType(ext.message)
columns message varchar2(20) path 'message',
errorCode varchar2(20) path 'errorCode',
status varchar2(10) path 'status'
) x;
MESSAGE ERRORCODE STATUS
-------------------- -------------------- ----------
Missing first name INVALID_ACC Failed
Dalam kedua kasus, Anda perlu menentukan ruang nama, dan sintaksnya berbeda. Baca selengkapnya tentang menggunakan fungsi ini .
Anda dapat menyisipkannya langsung ke tabel lain dengan insert into some_table (x, y, z) select ...
.