Not sure which OracleCommand method to use

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
phowe
Posts: 20
Joined: Fri 12 Jul 2013 16:51
Location: Maine

Not sure which OracleCommand method to use

Post by phowe » Tue 29 Apr 2014 13:17

I need to execute a stored procedure that does a whole bunch of work and returns several "out" parameters, but none of them are cursors or result sets (all scalar values.) My code looks like this:

Code: Select all

 
OracleCommand command = GetStoredProcCommandAndConnection("IP_APP_PKG.QUICKENTRY_ENTERPAYCHECK");

command.Parameters.Add("p_pclient_id", OracleDbType.Number, Convert.ToDecimal(pClientId),
                         ParameterDirection.Input);
command.Parameters.Add("p_userid", OracleDbType.Number, Convert.ToDecimal(userId),
                        ParameterDirection.Input);
command.Parameters.Add("p_employeename", OracleDbType.VarChar, employeename,
                       ParameterDirection.Input);
command.Parameters.Add("o_pagenmumber", OracleDbType.Number, dPageNumber, 
                       ParameterDirection.InputOutput);
command.Parameters.Add("o_no_of_pages", OracleDbType.Number, dNumberOfPages, 
                       ParameterDirection.Output);
command.Parameters.Add("o_ppagesize", OracleDbType.Number, dPageSize, 
                       ParameterDirection.Output);
command.Parameters.Add("o_totalemployees", OracleDbType.Number, dTotalEmployees,
                       ParameterDirection.Output);
command.Parameters.Add("o_sortorder", OracleDbType.VarChar, sortOrder, 
                       ParameterDirection.Input);
command.Parameters.Add("o_message", OracleDbType.VarChar, ParameterDirection.Output);

command.ExecuteScalar();  // TODO: Is this the right method to execute?
I don't know if ExecuteScalar will return all of the "out" parameters, of if I should use another method.

Anyone that knows the answer, please help.

Thanks,
Peter

Pinturiccio
Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Re: Not sure which OracleCommand method to use

Post by Pinturiccio » Wed 30 Apr 2014 15:27

We recommend you to use the ExecuteNonQuery method for executing this stored procedure because it doesn't return a result set. When you work with stored procedures, returning result sets, use the ExecuteReader() method.

Post Reply