简体   繁体   中英

Oracle data access output parameter mixed up

I am invoking an Oracle stored procedure witch contains 15 input parameters and 4 output parameters. Output parameters are set like this:

OracleParameter p_errn = cmd.Parameters.Add("pErrCode", OracleDbType.Decimal, 10);
                p_errn.Direction = ParameterDirection.Output;

                OracleParameter p_errm = cmd.Parameters.Add("pErrMsg", OracleDbType.Varchar2, 1000);
                p_errm.Direction = ParameterDirection.Output;

                OracleParameter pStatus = cmd.Parameters.Add("pStatus", OracleDbType.Decimal, 10); 
                pStatus.Direction = ParameterDirection.Output;

                OracleParameter pID = cmd.Parameters.Add("pID", OracleDbType.Varchar2, 1000);
                pID.Direction = ParameterDirection.Output;

Procedure i successfully executed but output paramers values are mixed up. Value that should be in pId is in pStatus, value that should be in pStatus is in pErrMsg and so on.

I have also tried to get values by getting from Parameter collection:

cmd.Parameters["pErrMsg"].Value.ToString()

but the situation is the same.

I have checked stored procedure, an everything seems fine. All the output parameters are set correctly.

Anyone had similar problem or some hint what causes this behaviour?

All the parameters must be added in the same order as they are defined in stored procedure on ORACLE .

One of the input parameters was added out of order and that caused the confusion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM