如何将字符串从Visual Studio 2012传递到Oracle包

时间:2014-06-18 17:01:36

标签: oracle visual-studio parameters plsql

套餐规范:

CREATE OR REPLACE PACKAGE TestArea
AS
    PROCEDURE DeleteTWCBLUSGProcessTable;
    PROCEDURE PrepTWCBLUSGProcessTable(sDate IN VARCHAR2);
END TestArea;

套餐正文:

CREATE OR REPLACE PACKAGE BODY MROBINSON28518.TestArea
AS
    PROCEDURE DeleteTWCBLUSGProcessTable
    IS
    BEGIN
    DELETE FROM MROBINSON28518.TWCBLUSG_PROCESSING;
    END DeleteTWCBLUSGProcessTable;

PROCEDURE PrepTWCBLUSGProcessTable(sDate IN VARCHAR2)
IS
BEGIN
   INSERT INTO mrobinson28518.TWCBLUSG_Processing
        (
        BillDate, 
        UBR_CARRIER, 
        UBR_BILL_GRP, 
        UBR_DIV, 
        UBR_EXCHANGE, 
        UBR_JUR, 
        UBR_EXCH_CARR, 
        UBR_DATE, 
        UBR_JDATE, 
        UBR_RATE_PD, 
        UBR_ELEMENT, 
        UBR_CALL, 
        UBR_TYPE, 
        UBR_QTY, 
        UBR_RATE, 
        UBR_AMOUNT, 
        UBR_MILEAGE, 
        UBR_OWN_PCT, 
        UBR_POP_CLLI, 
        UBR_FILLER)

        SELECT 
        sDate,
        A.UBR_CARRIER, 
        A.UBR_BILL_GRP, 
        A.UBR_DIV, 
        A.UBR_EXCHANGE, 
        A.UBR_JUR, 
        A.UBR_EXCH_CARR, 
        A.UBR_DATE, 
        A.UBR_JDATE, 
        A.UBR_RATE_PD, 
        A.UBR_ELEMENT, 
        A.UBR_CALL, 
        A.UBR_TYPE, 
        A.UBR_QTY, 
        A.UBR_RATE, 
        A.UBR_AMOUNT, 
        A.UBR_MILEAGE, 
        A.UBR_OWN_PCT, 
        A.UBR_POP_CLLI, 
        A.UBR_FILLER 
    FROM EUR_TWCBLUSG A; 
END PrepTWCBLUSGProcessTable;
END TestArea;

Visual Studio代码:

 private void btnExecute_Click(object sender, EventArgs e)
        {
            OracleConnection oCnt = new OracleConnection("Data Source=XXXX;User Id=XXXXXX;Password=XXXXXXXX");
            OracleCommand oCmd = new OracleCommand();
            try
            {
                oCmd.Connection = oCnt;
                oCmd.CommandType = CommandType.StoredProcedure;               
               oCmd.CommandText = "TestArea.PrepTWCBLUSGProcessTable";
               oCmd.Parameters.Add(
                       new OracleParameter()
                       {
                           ParameterName = "sDate",
                            OracleType = System.Data.OracleClient.OracleType.VarChar,
                           Direction = ParameterDirection.Input
                       }
                       );                                 
                oCnt.Open();
                oCmd.ExecuteNonQuery();            
                oCnt.Close();
            }//try

结果:

ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PREPTWCBLUSGPROCESSTABLE'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
你可以帮忙吗?

提前谢谢。

标记

1 个答案:

答案 0 :(得分:0)

           oCmd.Parameters.Add(
                   new OracleParameter()
                   {
                       ParameterName = "sDate",
                        OracleType = System.Data.OracleClient.OracleType.VarChar,
                       Direction = ParameterDirection.Input,
                       Value = "Something"
                   }
                   );

希望您还需要指定value属性。