Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trying to call a function from C#

998035Mar 20 2013 — edited Mar 20 2013
Hi all,

I am having problems calling a function that returns a sys refcursor and takes a varchar2 as an input. From the SQL Developer IDE I see that the function is run like

DECLARE
X_AR_MHTR VARCHAR2(200);
v_Return sys_refcursor;
BEGIN
X_AR_MHTR := 697678;

v_Return := CMS_SMS.FOR_WEB.WEB_STATION_1(
X_AR_MHTR => X_AR_MHTR
);
/* Legacy output:
DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
*/
:v_Return := v_Return; --<-- Cursor
END;


here is my C# code

public static void getTilemetriseis(bool isLemessos, string AMSet, out OracleDataReader dr)
{
DataSet ds = new DataSet();
OracleDataAdapter ad = new OracleDataAdapter();
OracleCommand cmd = new OracleCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "CMS_SMS.FOR_WEB.WEB_Station_1";

if (isLemessos)
{
cmd.Parameters.Add("X_AR_MHTR", OracleDbType.Varchar2, ConfigurationManager.AppSettings["LemessosArMhtr"].ToString(), ParameterDirection.Input);
cmd.Parameters.Add(new OracleParameter("anexoflCur", OracleDbType.RefCursor, ParameterDirection.ReturnValue));
// ad.SelectCommand.CommandText = string.Format(@"select m_code,ar_mhtr,city,address,stcode
// from cms_sms.FOR_WEB.flowmetersall where ar_mhtr = {0}
// order by length(ar_mhtr),ar_mhtr", ConfigurationManager.AppSettings["LemessosArMhtr"].ToString());
}
else
{
cmd.Parameters.Add("X_AR_MHTR", OracleDbType.Varchar2, "697678", ParameterDirection.Input);
cmd.Parameters.Add(new OracleParameter("v_Return", OracleDbType.RefCursor, ParameterDirection.ReturnValue));
// ad.SelectCommand.CommandText = string.Format(@"select m_code,ar_mhtr,city,address,stcode
// from cms_sms.FOR_WEB.flowmetersall where ar_mhtr= -1
// order by length(ar_mhtr),ar_mhtr", AMSet);
}
cmd.Connection = OracleDBManager.getOracleCMSConnection();
cmd.ExecuteNonQuery();
dr = (OracleDataReader)cmd.Parameters["v_Return"].Value;
cmd.Connection.Close();
}

The error rises on cmd.ExecuteNonQuery() and is described as

ORA-06550:
PLS-00306: wrong number or type of argument

Any ideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 17 2013
Added on Mar 20 2013
3 comments
15,072 views