Hi
We are using Oracle 10g as the database and want to insert the xml content in the table which contains the xmltype as the datatype.
I'm able to insert the xml content using insert statement but it is failing with the procedure.
Here is the code for insert statement: (Tried two ways, both are working fine with insert statement)
-----------------------------------------------------
insert into Report_structure
values(1,'summary',SYS.XMLTYPE.CREATEXML('<Warehouse whNo="100">
<Building>Owned</Building>
</Warehouse>'),'S','7');
insert into Report_structure values(1,'summary',XmlType('<Warehouse whNo="100">
<Building>Owned</Building>
</Warehouse>'),'S','7');
Here is the code for procedure:
--------------------------------------------
PROCEDURE add_report(p_node_id IN ws_report_structure.parent_node_id%TYPE,
p_report_name IN ws_reports.report_name%TYPE,
p_report_xml IN ws_reports.report_xml%TYPE) AS
v_report_id INTEGER;
v_context DBMS_XMLStore.ctxType;
-- procedure to add the report. New report id is generated and a record is placed
-- in WS_REPORTS table. Followed to that an entry is made in WS_REPORT_STRUCTURE
-- table as well, to tag hte current report/any other file created under a parent
BEGIN
IF p_node_id IS NULL THEN
RAISE_APPLICATION_ERROR(-20107,
'Report-Parent Node Id cannot be empty');
END IF;
IF p_report_name IS NULL THEN
RAISE_APPLICATION_ERROR(-20108, 'Report Name cannot be empty');
END IF;
-- get the next val fro the sequence to insert it into WS_REPORT_STRUCTURE table
Select Seq_Report_Id.Nextval INTO v_report_id FROM DUAL;
/* INSERT INTO ws_reports WR
(report_id, report_name, report_xml, created_date)
VALUES
(SEQ_report_id.nextval, p_report_name, p_report_xml,sysdate);
*/
COMMIT;
-- generate a node id & attach it to ws_report_structure table with the parent_node_id
INSERT INTO ws_report_structure
(node_id, parent_node_id, node_name, report_id)
VALUES
(seq_report_node_id.nextval, p_node_id, p_report_name, v_report_id);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
-- log it in the cyrus logger with key cyrus_ws
p_cyrus_logger.error('Failed to Add Report' || SQLERRM, 'CYRUS_WS');
END add_report;
Please let me know any ideas to resolve this issue.
Thanks in advance