C# - ORA-06550:调用' DOPROCESS'中的参数数量或类型错误

时间:2016-10-17 18:05:05

标签: c# asp.net plsql oracle11g

编辑:请参阅第2期

我已经搜索了这里的线程,我无法弄清楚为什么我收到了ORA-06550消息。

Oracle中的PL / SQL进程没有错误。

存储的PROC接收5个参数,我正在输出单个NUMBER参数进行异常处理。

请告诉我我做错了什么。

PL / SQL

PROCEDURE DoProcess( ocn IN WAREHOUSE.BANK_STATEMENT_ACTIVITY.CHECK_NO%TYPE,
                     oca IN WAREHOUSE.BANK_STATEMENT_ACTIVITY.AMOUNT%TYPE,
                     ecn IN WAREHOUSE.BANK_STATEMENT_ACTIVITY.CHECK_NO%TYPE,
                     eca IN WAREHOUSE.BANK_STATEMENT_ACTIVITY.AMOUNT%TYPE,
                     usr IN WAREHOUSE.BANK_STATEMENT_ACTIVITY.OVERRIDDEN_USER_ID%TYPE,
                     errCode OUT NUMBER )
AS
BEGIN
    Initialize( ocn, oca, ecn, eca, usr );
    DBMS_OUTPUT.PUT_LINE('ocn: ' || ocn || CHR(10) ||
                         'oca: ' || oca || CHR(10) ||
                         'ecn: ' || ecn || CHR(10) ||
                         'eca: ' || eca || CHR(10) ||
                         'usr: ' || usr);
    IF IsValid( bsa_rec.CHECK_NO, errCode ) THEN UpdateProc;
    --DBMS_OUTPUT.PUT_LINE('errCode: ' || errCode);
    END IF;
END DoProcess;

C#

public Int32 BankDataExceptionsDoProcess(string ckNo, string ckAmt, string checkNo, string checkAmt, string user)
    {
        Int32 errCode = 0;

        ckNo  = ckNo.Trim();
        double dblCkAmt = double.Parse(ckAmt.Trim());
        checkNo = checkNo.Trim();
        double dblCheckAmt = double.Parse(checkAmt.Trim());
        int uid = int.Parse(user);


        object obj = null;

        if (DBC == null)
            DBC = new DBConn();

        DBC.ExecutePackage(Vars.pkgBankDataExceptions,
                           out obj,
                           new ParameterDirection[] { ParameterDirection.Input,
                                                      ParameterDirection.Input,
                                                      ParameterDirection.Input,
                                                      ParameterDirection.Input,
                                                      ParameterDirection.Input,
                                                      ParameterDirection.Output },
                           new object[] { ckNo, dblCkAmt, checkNo, dblCheckAmt, uid, errCode }
                          );

        return errCode;
    }

2 个答案:

答案 0 :(得分:0)

您不能将现有变量用于ADO.NET中的OUTPUT参数。

cmd.Parameters.Add("OutputParam", OracleDbType.Int32).Direction = ParameterDirection.Output;

然后在执行后引用它:

if(cmd.Parameters["OutputParam"] != null)
{
   int returnValue = int.Parse(cmd.Parameters["OutputParam"].Value);
}

答案 1 :(得分:0)

我错过了一小撮代码。看来默认的out对象包含所有字符串,与oracle数据类型无关。

以下是缺少的代码:

errCode = int.Parse(obj.ToString());

整个C#方法:

public int BankStmntExceptionsDoProcess(string ckNo, string ckAmt, string checkNo, string checkAmt, string user)
    {
        int errCode = 0;;

        ckNo     = ckNo.Trim();
        ckAmt    = ckAmt.Trim();
        checkNo  = checkNo.Trim();
        checkAmt = checkAmt.Trim();
        user     = user.Trim();

        object obj = null;

        if (DBC == null)
            DBC = new DBConn();

        DBC.ExecutePackage(Vars.pkgBankStatementProcessing,
                           out obj,
                           new ParameterDirection[] { ParameterDirection.Input,
                                                      ParameterDirection.Input,
                                                      ParameterDirection.Input,
                                                      ParameterDirection.Input,
                                                      ParameterDirection.Input,
                                                      ParameterDirection.Output,
                                                    },
                           new object[] { ckNo, ckAmt, checkNo, checkAmt, user, errCode }
                           );

        errCode = int.Parse(obj.ToString());

        return errCode;
    }