INSERTCHILDXML
Note:
The INSERTCHILDXML function is deprecated. It is still supported for backward compatibility. However, Oracle recommends that you use XQuery Update instead. See Oracle XML DB Developer's Guide for more information.
Syntax
Purpose
INSERTCHILDXML inserts a user-supplied value into the target XML at the node indicated by the XPath expression. Compare this function with INSERTXMLBEFORE.
-
XMLType_instanceis an instance ofXMLType. -
XPath_stringis an Xpath expression indicating one or more nodes into which the one or more child nodes are to be inserted. You can specify an absoluteXPath_stringwith an initial slash or a relativeXPath_stringby omitting the initial slash. If you omit the initial slash, then the context of the relative path defaults to the root node. -
child_exprspecifies the one or more element or attribute nodes to be inserted. -
value_expris an fragment ofXMLTypethat specifies one or more notes being inserted. It must resolve to a string. -
The optional
namespace_stringprovides namespace information for theXPath_string. This parameter must be of typeVARCHAR2.
See Also:
Oracle XML DB Developer's Guide for more information about this function
Examples
The following example adds a second /Owner node to the warehouse_spec of one of the warehouses updated in the example for APPENDCHILDXML:
UPDATE warehouses
SET warehouse_spec = INSERTCHILDXML(warehouse_spec, '/Warehouse/Building',
'Owner', XMLType('<Owner>LesserCo</Owner>'))
WHERE warehouse_id = 3;
SELECT warehouse_spec
FROM warehouses WHERE warehouse_id = 3;
WAREHOUSE_SPEC
----------------------------------------------------------------------------
<?xml version="1.0"?>
<Warehouse>
<Building>Rented
<Owner>Grandco</Owner>
<Owner>LesserCo</Owner>
</Building>
<Area>85700</Area>
<DockType/>
<WaterAccess>N</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>11.5 ft</VClearance>
</Warehouse>