I'm trying to save a CLOB
into a variable to perform operations like extract and such. I have this code:
DECLARE
clob_rec CLOB;
n_rec NUMBER:=100;
BEGIN
SELECT LOB INTO clob_rec FROM table1 WHERE ID = 1234;
n_rec := clob_rec.EXTRACT('//XPTO/text()', 'xmlns:XPTO').getNumVal();
END;
I want to save multiple values from the XML
to various variables like n_rec
. How can get an "instance of the object (CLOB)" to perform functions or methods like extract()
?
You need to convert it to an XMLtype first:
DECLARE
clob_rec CLOB;
n_rec NUMBER:=100;
x XMLType;
BEGIN
SELECT LOB INTO clob_rec FROM table1 WHERE ID = 1234;
x := XMLType(clob_rec);
n_rec := x.EXTRACT('//XPTO/text()', 'xmlns:XPTO').getNumVal();
END;