Not sure which OracleCommand method to use

Not sure which OracleCommand method to use

Postby 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),
command.Parameters.Add("p_userid", OracleDbType.Number, Convert.ToDecimal(userId),
command.Parameters.Add("p_employeename", OracleDbType.VarChar, employeename,
command.Parameters.Add("o_pagenmumber", OracleDbType.Number, dPageNumber,
command.Parameters.Add("o_no_of_pages", OracleDbType.Number, dNumberOfPages,
command.Parameters.Add("o_ppagesize", OracleDbType.Number, dPageSize,
command.Parameters.Add("o_totalemployees", OracleDbType.Number, dTotalEmployees,
command.Parameters.Add("o_sortorder", OracleDbType.VarChar, sortOrder,
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.

Posts: 20
Joined: Fri 12 Jul 2013 16:51
Location: Maine

Re: Not sure which OracleCommand method to use

Postby 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.
Devart Team
Posts: 2062
Joined: Wed 02 Nov 2011 09:44

Return to dotConnect for Oracle