ORA-01036:过程返回结果集中的非法变量名称/编号

时间:2015-08-21 12:15:26

标签: c# asp.net oracle ado.net

我看到很多人都在问这个问题,但我认为我有不同的情况。没有什么能解决我的问题所以想到在这里发布它。我在oracle中创建了一些程序,它给了我一些表数据。看看程序。

CREATE OR REPLACE PROCEDURE SMSUADMIN.GetSmsDataByMobileNo
(
MobileNo IN VARCHAR2 := '',
data_c OUT sys_refcursor
)
 IS


BEGIN

    OPEN data_c FOR 
    select v.TOMOBILE,v.SMS_COMPUTED_TEXT SMS_TEXT,v.CREATED_ON 
    sent_date,v.DONE_DATE Received_date,s.SE_ERROR_DESCRIPTION STATUS from 
    TBL_VF_FINAL_STATUS v
    join  SMS_ERROR_MASTER s  on v.ERROR_CODE=s.SE_DECIMAL_VALUE
    join  TBL_SMS_JOB_REQUEST J on j.JOB_REQ_ID  =V.JOB_REQ_ID 
    Where ToMobile = MobileNo;


   EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      NULL;
   WHEN OTHERS
   THEN
      RAISE;
END GetSmsDataByMobileNo;
当我从TOAD运行它时,

工作正常。但是当我从ASP.Net应用程序调用它时,它会给出错误

堆栈跟踪看起来也很令人沮丧。

   at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc)
   at System.Data.OracleClient.OracleParameterBinding.Bind(OciStatementHandle statementHandle, NativeBuffer parameterBuffer, OracleConnection connection, Boolean& mustRelease, SafeHandle& handleToBind)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, ArrayList& resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior)
   at LMS_SMS.DataAccess.DALSms.GetSmsDetails(String mobileNo, String token) in e:\Imad\LEAP_V1.0\DEV\Leap_WCF\LMS_SMS\DataAccess\DALSms.cs:line 42

我正在调用这样的程序

                OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["SMSValueFirstConnectionString"].ToString());
                OracleCommand cmd = new OracleCommand("GetSmsDataByMobileNo", con);
                System.Data.OracleClient.OracleParameter param = new System.Data.OracleClient.OracleParameter 
                                            {
                                                OracleType = OracleType.VarChar, 
                                                Value = mobileNo, 
                                                Direction = System.Data.ParameterDirection.Input,
                                                ParameterName = "MobileNo"      
                                            };

                OracleParameter param1 = new OracleParameter
                {
                    OracleType = OracleType.Cursor,
                    Direction = System.Data.ParameterDirection.Output,
                    ParameterName = "data_c"
                };

                cmd.Parameters.Add(param);
                cmd.Parameters.Add(param1);
                con.Open();
                OracleDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);                     

                while (reader.Read())
                {
                    smsEntities.Add(new SmsEntity
                    {
                        Delivery_Date = Convert.ToDateTime(reader["TOMOBILE"]),
                        Delivery_Status = Convert.ToBoolean(reader["STATUS"]),
                        MobileNo = Convert.ToString(reader["TOMOBILE"]),
                        Remarks = Convert.ToString(reader["SE_ERROR_DESCRIPTION"]),
                        SMS_Text = Convert.ToString(reader["SMS_TEXT"])
                    });
                }
                cmd.Parameters.Clear();
                con.Close();

有一段时间我觉得问题可能是我的连接字符串,但如果有问题那么它就不允许我打开连接,对吧?

我在cmd.ExecuteReader()上有或没有参数的情况下超过了异常。请帮我解决这个问题。

0 个答案:

没有答案