Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Oracle数据库中使用SQL从CLOB数据中提取数据_Oracle_Jdb - Fatal编程技术网

从Oracle数据库中使用SQL从CLOB数据中提取数据

从Oracle数据库中使用SQL从CLOB数据中提取数据,oracle,jdb,Oracle,Jdb,我有一个名为device的表,其中包含一个名为XMLdoc的CLOB数据类型列。我想更新值字段 Name=DropDirectory值= 您没有指定您的Oracle版本。我猜是11克。。注意:如果您使用的是12c,那么可能应该使用XQuery 在这里,我将Value属性更新为新的_值 select xmlserialize(content updatexml(xmltype( '<Attributes> <Attribute DataType="Text-40" Dis

我有一个名为device的表,其中包含一个名为XMLdoc的CLOB数据类型列。我想更新值字段

Name=DropDirectory值=


您没有指定您的Oracle版本。我猜是11克。。注意:如果您使用的是12c,那么可能应该使用XQuery

在这里,我将Value属性更新为新的_值

select xmlserialize(content updatexml(xmltype(
'<Attributes>
    <Attribute DataType="Text-40" DisplayName="PrinterAlias"
        IsNotDeletable="Y" Modifiable="Y" Name="PrinterAlias" Value="QALABHP"/>
    <Attribute DisplayName="PrintServerHostName"
        Name="PrintServerHostName" Value="zzzzz"/>
    <Attribute DisplayName="PrintServerPort" Name="PrintServerPort" Value="2723"/>
    <Attribute DataType="Text-40" DisplayName="DropDirectory"
        IsNotDeletable="Y" Modifiable="Y" Name="DropDirectory" Value=""/>
</Attributes>'), '/Attributes/Attribute[@Name="DropDirectory"]/@Value', 'new_value'))
from dual
结果CLOB:


您可以按以下方式进行更新:

选择:

SELECT extract(xmltype(col1), '/Attributes/Attribute[@Name="DropDirectory"]/@Value') 
  FROM test_clob;
输出:

 SQL> SELECT extract(xmltype(col1), '/Attributes/Attribute[@Name="DropDirectory"]/@Value') 
  FROM test_clob;    

EXTRACT(XMLTYPE(COL1),'/ATTRIBUTES/ATTRIBUTE[@NAME="DROPDIRECTORY"]/@VALUE')
--------------------------------------------------------------------------------
 SQL> /

EXTRACT(XMLTYPE(COL1),'/ATTRIBUTES/ATTRIBUTE[@NAME="DROPDIRECTORY"]/@VALUE')
--------------------------------------------------------------------------------
google.com
更新:

 UPDATE test_clob 
  SET col1 =   UPDATEXML(xmltype(col1),
   '/Attributes/Attribute[@Name="DropDirectory"]/@Value',to_char('google.com')).getClobVal()
输出:

 SQL> SELECT extract(xmltype(col1), '/Attributes/Attribute[@Name="DropDirectory"]/@Value') 
  FROM test_clob;    

EXTRACT(XMLTYPE(COL1),'/ATTRIBUTES/ATTRIBUTE[@NAME="DROPDIRECTORY"]/@VALUE')
--------------------------------------------------------------------------------
 SQL> /

EXTRACT(XMLTYPE(COL1),'/ATTRIBUTES/ATTRIBUTE[@NAME="DROPDIRECTORY"]/@VALUE')
--------------------------------------------------------------------------------
google.com

注意:将您的tablename和columnname替换为我的。

您的问题是什么?XMLType.getClobVal方法已被弃用,应使用XMLSerialize。