C# - ODP.NET: How to get XML from Oracle stored procedure?
519887Jun 27 2006 — edited Jun 27 2006Hi friends,
In SQL Server 2000, we have FOR XML [Auto | Raw | Explicit] clause and we can get XML from stored procedure using SQLCommand's ExecuteXMLReader method.
What's the equivalent for C# - Oracle10g scenario? Can you pls.send me a simple stored procedure & C# source code to get XML from stored proc.?
Let me explain with example :
* Scenario : C# - SQL Server 2000
In SQL Server 2000, I've a table called tblEmp.
To get all the records in tblEmp, I write following stored procedure:
--------------------------------------------------------
CREATE PROCEDURE spGetEmp AS
SELECT * FROM tblEmp
FOR XML RAW
The above stored procedure returns the result -
--------------------------------------------------------
<row EMPID="1" EMPNAME="John" ADDR="A/101, AB"/>
<row EMPID="2" EMPNAME="Scott" ADDR="B/101, CD"/>
<row EMPID="3" EMPNAME="Chuck" ADDR="C/101 EF"/>
In C#, I use SQLCommand.ExecuteXmlReader( xxxxxx ) to execute the stored procedure and get the result in XmlReader object.
Now, how do I achieve the same with Oracle10g as backend.
I need -
1) How to write a stored procedure?
2) What should be my frontend code (C#)
ODP.NET's OracleCommand does have ExecuteXmlReader method, but I don't have any idea how to use it...
PS. I need the result same as the SQL Server's...
Thanks,
Amit