Oracle 10g:从XML(CLOB类型)提取数据(选择) [英] Oracle 10g: Extract data (select) from XML (CLOB Type)
本文介绍了Oracle 10g:从XML(CLOB类型)提取数据(选择)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Oracle的新手,而且我(也许是微不足道的)选择问题. (我正在使用Oracle 10g Express Edition).
I'm new in Oracle and I've - maybe trivial - a problem in a select. (I'm using Oracle 10g Express Edition).
我有一个具有CLOB字段的数据库:mytab.xml 该列具有这样的XML:
I've a DB with a field CLOB: mytab.xml This column have an XML like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<info>
<id> 954 </id>
<idboss> 954 </idboss>
<name> Fausto </name>
<sorname> Anonimo </sorname>
<phone> 040000000 </phone>
<fax> 040000001 </fax>
</info>
我正在尝试执行简单"选择,以获取例如"fax"标签的值.但是我有一些问题,我无法理解我的错误.例如:
I'm trying to do a 'simple' select to get, for example, the value of 'fax' tag. But I've a bit of problem and I'm not able to understand my error. For example:
select extract(xml, '//fax').getStringVal() from mytab;
ORA-00932: inconsistent datatypes: expected - got
select extract(xmltype(xml), '//fax').getStringVal() from mytab;
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.XMLTYPE", line 254
我也尝试过使用'extractvalue',但是我遇到了同样的问题. 我在哪里做错了?
I've tryed also with 'extractvalue', but I've the same problems. where I'm wrong to do this?
推荐答案
尝试以下方法:
select xmltype(t.xml).extract('//fax/text()').getStringVal() from mytab t
这篇关于Oracle 10g:从XML(CLOB类型)提取数据(选择)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文