Getting XML Data from query

declare
QRY_HANDLE_INFO DBMS_XMLGEN.CTXHANDLE;
V_ORDER_DETAILS_QUERY varchar2(100);
v_xml_result CLOB;

begin
V_ORDER_DETAILS_QUERY:=’select sysdate from dual’;
— DBMS_XMLGEN.SETROWSETTAG(QRY_HANDLE_INFO, ‘Headers’);
— DBMS_XMLGEN.setRowTag(qry_handle_info, ‘Header’);
QRY_HANDLE_INFO:=DBMS_XMLGEN.NEWCONTEXT(V_ORDER_DETAILS_QUERY);
V_XML_RESULT:=DBMS_XMLGEN.GETXML(QRY_HANDLE_INFO);
v_xml_result := REPLACE( v_xml_result
, ‘<?xml version=”1.0″?>’
, ‘<?xml version=”1.0″ encoding=”ISO-8859-1″ ?>’ );
DBMS_OUTPUT.PUT_LINE(V_XML_RESULT);
DBMS_XMLGEN.closeContext (qry_handle_info);
end;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s