我正在尝试将CLOB
保存到变量中以执行提取等操作。我有这段代码:
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;
我想将XML
中的多个值保存到n_rec
等各种变量中。如何获得“对象实例(CLOB)”来执行extract()
等函数或方法?
答案 0 :(得分:5)
您需要先将其转换为XMLtype:
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;