-- xmldelete.sql

SET SERVEROUTPUT ON

DECLARE
  context DBMS_XMLSTORE.CtxType;
  rowcount NUMBER;
  xmlData CLOB :=      --  XML data set here
    '<ROWSET>
       <ROW num="1">
         <ID>1</ID>
       </ROW>
       <ROW>
         <ID>2</ID>
       </ROW>
     </ROWSET>';
BEGIN
  context := DBMS_XMLSTORE.NEWCONTEXT('S1.PERSON'); -- get context
  DBMS_XMLSTORE.SETKEYCOLUMN(context,'ID');
  rowcount := DBMS_XMLSTORE.DELETEXML(context, xmlData);
  DBMS_XMLSTORE.CLOSECONTEXT(context);
  DBMS_OUTPUT.PUT_LINE(rowcount || ' rows where deleted');
END;
/

