Home » Developer & Programmer » JDeveloper, Java & XML » Hi problem in exporting data to xml file
Hi problem in exporting data to xml file [message #135338] Wed, 31 August 2005 02:45 Go to next message
ramabhupalrr
Messages: 69
Registered: July 2005
Location: India
Member

Hi all,

I want to move the table data to xml file.

I have written this procedure .

create or replace procedure tabletoxml
as
Ctx DBMS_XMLGEN.ctxHandle;
xml clob;

xmlc varchar2(4000);
off integer := 1;
len integer := 4000;
BEGIN
Ctx := DBMS_XMLGEN.newContext('SELECT client_no FROM client_master ');
DBMS_XMLGen.setRowsetTag(Ctx, 'EMP_TABLE');
DBMS_XMLGen.setRowTag(Ctx, 'EMP_ROW');
DBMS_XMLGEN.closeContext(Ctx);
xml:=DBMS_XMLGEN.getXML(Ctx);

DBMS_LOB.READ(xml, len, off, xmlc); DBMS_OUTPUT.PUT_LINE(xmlc);
END;


But i am getting the following error.
ORA-19019: Invalid context passed to DBMS_XMLGEN.GETXML
ORA-06512: at "SYS.DBMS_XMLGEN", line 7
ORA-06512: at "SYS.DBMS_XMLGEN", line 147
ORA-06512: at "PLLC.TABLETOXML", line 14


Any suggestions will be appreciated.

Thanks,
Bhupal.

[Updated on: Wed, 31 August 2005 04:01]

Report message to a moderator

Re: Hi problem in exporting data to xml file [message #238571 is a reply to message #135338] Fri, 18 May 2007 09:46 Go to previous message
A_nony_mouse
Messages: 1
Registered: May 2007
Junior Member
ramabhupalrr wrote on Wed, 31 August 2005 03:45
Hi all,

I want to move the table data to xml file.

I have written this procedure .

create or replace procedure tabletoxml
as
Ctx DBMS_XMLGEN.ctxHandle;
xml clob;

xmlc varchar2(4000);
off integer := 1;
len integer := 4000;
BEGIN
Ctx := DBMS_XMLGEN.newContext('SELECT client_no FROM client_master ');
DBMS_XMLGen.setRowsetTag(Ctx, 'EMP_TABLE');
DBMS_XMLGen.setRowTag(Ctx, 'EMP_ROW');
DBMS_XMLGEN.closeContext(Ctx);
xml:=DBMS_XMLGEN.getXML(Ctx);

DBMS_LOB.READ(xml, len, off, xmlc); DBMS_OUTPUT.PUT_LINE(xmlc);
END;


But i am getting the following error.
ORA-19019: Invalid context passed to DBMS_XMLGEN.GETXML
ORA-06512: at "SYS.DBMS_XMLGEN", line 7
ORA-06512: at "SYS.DBMS_XMLGEN", line 147
ORA-06512: at "PLLC.TABLETOXML", line 14


Any suggestions will be appreciated.

Thanks,
Bhupal.



Since I was just playing with the same procedure (from the Oracle DBMS_XMLGEN example) with my own query, thought I'd include the solution.

The example from Oracle does DBMS_XMLGEN.closeContext(Ctx); before xml:=DBMS_XMLGEN.getXML(Ctx); so of course the context is invalid. Do xml:=DBMS_XMLGEN.getXML(Ctx); first and DBMS_XMLGEN.closeContext(Ctx); after and all will be well.
Previous Topic: Protocol Violation with 10gR2
Next Topic: Special character in Clob field - ¿
Goto Forum:
  


Current Time: Thu Mar 28 14:59:06 CDT 2024