0

I'm trying to create a XML in stored procedure in this way:

PROCEDURE DeviceSearched(
   xml_out OUT XMLTYPE
)
IS
BEGIN

    SELECT 
      XMLELEMENT("Values", 
          XMLFOREST(de_brand)
    ) 
    INTO xml_out
    FROM 
      tbldevice de 
    ;  

END DeviceSearched;

And I trying to read xml_out in c# in this way:

...
OracleCommand command = new OracleCommand(name, conn);
command.CommandType = CommandType.StoredProcedure;
command.BindByName = true;
...
command.Parameters.Add(new OracleParameter("xml_out", OracleDbType.XmlType, ParameterDirection.Output));

With this approach the issues are two:

  1. Oracle exception: "ORA-01422: exact fetch returns more than requested number of rows"
  2. If I modify the query to obtain one row, the procedure is ok (I think), but in c# I don't have any result.

What am I doing wrong?

Thanks in advance

1
  • any full source code sample about it? Commented Aug 28, 2013 at 15:43

1 Answer 1

1
  • Running
    SELECT XMLELEMENT("Values",XMLFOREST(de_brand)) FROM tbldevice de In plsql will NOT result a single value, So trying to fetch the result in to single variable (INTO xml_out) will result run time error ORA-01422

  • Using a store procedure to select data in Oracle is not apperciated, its a SQL Server approch, why not using a simple select

  • Examples here and here will show how ODP.Net works with XML
    You may need to mix using ref corsur and XMLType to solve the matter

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

Comments

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.