I worked through the example through the Oracle documentation page for the UPDATEXML function: https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions205.htm
Now, I'm trying to apply this to the data in my database. The column in my database is CLOB (used for multiple things), so I need to convert my data to the xmltype before performing xml related operations. However, my attempt is returning the following error SQL Error: ORA-00927: missing equal sign.
Is there a way to update the clob-stored xml without modifying the column data type?
Attempt
Reusing the Oracle example with datatypes of my database.
1. Creating table
CREATE TABLE xwarehouses
(
MSD_ID INTEGER,
CDATA CLOB
);
2. Adding data
INSERT INTO xwarehouses VALUES
(1,
('<?xml version="1.0"?>
<Warehouse>
<WarehouseId>1</WarehouseId>
<WarehouseName>Southlake, Texas</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>'));
3. Converting CLOB to XMLTYPE to extract value from specified tag
SELECT EXTRACTVALUE(XMLTYPE(cdata),'/Warehouse/WaterAccess') as VAL from xwarehouses;
VAL | true
4. Attempt to update value using same conversion in UPDATE
update XWAREHOUSES
set XMLTYPE(cdata) =
updatexml(XMLTYPE(cdata),'/Warehouse/WaterAccess/text()','false')
where msd_id = 1;
**5. This returns the error:
SQL Error: ORA-00927: missing equal sign
SQL Error: ORA-00932: inconsistent datatypes: expected CLOB got - 00932. 00000 - "inconsistent datatypes: expected %s got %s".SQL Error: ORA-00932: inconsistent datatypes: expected - got - 00932. 00000 - "inconsistent datatypes: expected %s got %s"