0

I will be getting few records from database using SQL query in a stored procedure , My requirement is that I need to convert these records in to XML format and send this XML as an OUT PARAM in the same stored Procedure.

Can you kindly help us

Thanks!!

2 Answers 2

3

DBMS_XMLGEN.GETXML can turn a query into XML. For example:

select DBMS_XMLGEN.GETXML (q'!
    select 1 value1, 'asdf' value2 from dual union all
    select 2 value2, 'fdsa' value2 from dual    
!') from dual;

Returns a CLOB with this data:

<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <VALUE1>1</VALUE1>
  <VALUE2>asdf</VALUE2>
 </ROW>
 <ROW>
  <VALUE1>2</VALUE1>
  <VALUE2>fdsa</VALUE2>
 </ROW>
</ROWSET>

In a stored procedure, select this into an OUT CLOB parameter.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Jonearles .. I implemented it , Its working fine :-) Thank u so much!!
2

If your requirements are more complicated than being able to use just a SQL statement as suggested by jonearles, another option is the XMLDOM package, which will allow you to create XML using PL/SQL.

It's more complicated than DBMS_XMLGEN, but it's also more powerful.

1 Comment

As of now above suggested one is working , If I face any diffucluty I will go thorugh your suggestion also .. Thanks :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.