INSERTXMLBEFORE
Note:
The INSERTXMLBEFORE 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
INSERTXMLBEFORE inserts a user-supplied value into the target XML before the node indicated by the XPath expression. This function is similar to INSERTXMLAFTER, but it inserts before, not after, the target node. Compare this function with INSERTCHILDXML.
                  
- 
                        XMLType_instanceis an instance ofXMLType.
- 
                        XPath_stringis an Xpath expression indicating one or more nodes into which 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.
- 
                        value_expris a fragment ofXMLTypethat defines one or more nodes being inserted and their position within the parent node. 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 is similar to that for INSERTCHILDXML, but it adds a third /Owner node before the /Owner node added in the other example. The output of the query has been formatted for readability.
                  
UPDATE warehouses
  SET warehouse_spec = INSERTXMLBEFORE(warehouse_spec,
    '/Warehouse/Building/Owner[2]', XMLType('<Owner>ThirdOwner</Owner>'))
  WHERE warehouse_id = 3;
SELECT warehouse_name,
       EXTRACT(warehouse_spec, '/Warehouse/Building/Owner') "Owners"
  FROM warehouses
  WHERE warehouse_id = 3;
WAREHOUSE_NAME                      Owners
----------------------------------- ------------------------------
New Jersey                          <Owner>GrandCo</Owner>
                                    <Owner>ThirdOwner</Owner>
                                    <Owner>LesserCo</Owner>