1 Reply Latest reply: Jun 30, 2012 3:02 AM by odie_63 RSS

    DBMS_XMLDOM.SETNODEVALUEASCHARACTERSTREAM to set clob for Node Value

    834081
      I am trying to create an xml document using XML_DOM and then insert the xmltype into a table. The text of one of the nodes needs to be a CLOB. I have tried this:
      v_cf_node     :=     xmldom.makeNode(v_doc);
      v_cf_elem     :=     xmldom.createelement(v_doc,'TEMPID');
      --     v_cf_node     :=     xmldom.appendChild( v_main_node, xmldom.makeNode(v_cf_elem));
      v_text_Stream     := DBMS_XMLDOM.SETNODEVALUEASCHARACTERSTREAM (v_cf_node);

      WHILE (v_pos) <= dbms_lob.getlength(v_value) LOOP
      DBMS_LOB.READ(v_value,v_amt,v_pos,v_buffer);
      v_text_stream.write(v_buffer,v_pos);
      v_pos     :=     v_pos + LENGTH(v_buffer);
      END LOOP;

      I have tried numerous things commenting out makeNode causes :
      ORA-31020: The operation is not allowed, Reason: Null stream handle
      ORA-06512: at "XDB.DBMS_XMLDOM", line 2067
      ORA-06512: at "XDB.DBMS_XMLDOM", line 2111
      ORA-06512: at "SYS.XMLCHARACTEROUTPUTSTREAM", line 29
      ORA-06512: at line 75
      leaving it in causes :
      ERROR at line 1:
      ORA-30994: Invalid argument for DOM stream
      ORA-06512: at "XDB.DBMS_XMLDOM", line 2053
      ORA-06512: at "SYS.XMLCHARACTEROUTPUTSTREAM", line 6
      ORA-06512: at "XDB.DBMS_XMLDOM", line 1692
      ORA-06512: at line 71
      what am i doing wrong?