开发者

Issue using Oracle ODBC driver in Script Task in SSIS 2008

开发者 https://www.devze.com 2023-03-20 21:12 出处:网络
The issue I\'m having may not have anything to do with SSIS but I wanted to be thorough.I am attempting to have essentially the same code (using ODBC) accessing SQL Server, Sybase, and Oracle.Everythi

The issue I'm having may not have anything to do with SSIS but I wanted to be thorough. I am attempting to have essentially the same code (using ODBC) accessing SQL Server, Sybase, and Oracle. Everything except Oracle is working (not surprising) but I'm at a loss as to how to resolve this issue.

The Oracle driver is the 11.01.00.06 version. I am able to connect successfully to the instance but the call (to the function) fails. I'm guessing the error has to do with the fact that the cursor is a parameter in this case (not true for SQL Server and Sybase) and I am not accounting for it. There is no OdbcType for cursor though.

Any help or suggestions would be appreciated.

The error I am getting is - ERROR [07001] [Oracle][ODBC][Ora]ORA-01008: not all variables bound

Calling code (C#)

    NetworkProviderCon = new OdbcConnection(strCon);
    NetworkProviderCon.Open();
    NetworkProviderCmd.Connection = NetworkProviderCon;

    NetworkProviderCmd.CommandType = CommandType.StoredProcedure;

    NetworkProviderCmd.CommandText = "{CALL SP_NETWORK_IDL(?,?)}";

    NetworkProviderCmd.CommandTimeout = this.Variables.CADATABASECORETIMEOUT;

    //parameters to call SP   
    NetworkProviderParam1 = NetworkProviderCmd.Parameters.Add("@pdtStartTime", OdbcType.DateTime);
    NetworkProviderParam1.Value = strStartDate;
    NetworkProviderParam2 = NetworkProviderCmd.Parameters.Add("@pdtEndTime", OdbcType.DateTime);
    NetworkProviderParam2.Value = strEndDate;
    sqlDr = NetworkProviderCmd.ExecuteReader();

Procedure Parameters

CREATE OR REPLACE function XXXX.SP_NETWORK_IDL
(
开发者_开发技巧/*************************************************
** Declare Parameters                           **
*************************************************/

   pRESULT_CURSOR IN OUT CURSOR_PACKAGE.RESULT_CURSOR               ,
   pdtStartTime   IN     CMC_NWPR_RELATION.NWPR_TERM_DT%TYPE := NULL,
   pdtEndTime     IN     CMC_NWPR_RELATION.NWPR_EFF_DT%TYPE  := NULL
)
return number


Your function requests 3 parameters, but you are passing only 2.

NetworkProviderCmd.Parameters.Add
  ("@pRESULT_CURSOR", OracleType.Cursor).Direction = ParameterDirection.InputOutput;
//NetworkProviderCmd.Parameters["pRESULT_CURSOR"].Value will store your output

UPD:

MSDN: Using Parameters with an OleDbCommand or OdbcCommand

NetworkProviderParam0 = NetworkProviderCmd.Parameters.Add("@pRESULT_CURSOR", OracleType.Cursor);
NetworkProviderParam0.Direction = ParameterDirection.InputOutput;

P.S.: I can not find OdbcType for cursor

UPD2:

NetworkProviderCon = new OdbcConnection(strCon);
NetworkProviderCon.Open();

OdbcCommand NetworkProviderCmd = new OdbcCommand();
NetworkProviderCmd.CommandText = "{? = SP_NETWORK_IDL(?,?,?)}";
NetworkProviderCmd.Connection = NetworkProviderCon;
NetworkProviderCmd.CommandTimeout = this.Variables.CADATABASECORETIMEOUT;
NetworkProviderCmd.CommandType = CommandType.StoredProcedure;

//parameters to call SP 
NetworkProviderCmd.Parameters.Add("pRESULT_CURSOR", OracleType.Cursor).Direction = ParameterDirection.InputOutput; //NetworkProviderParam1
NetworkProviderCmd.Parameters.Add("pdtStartTime", OdbcType.DateTime).Value = strStartDate; //NetworkProviderParam2
NetworkProviderCmd.Parameters.Add("pdtEndTime", OdbcType.DateTime).Value = strEndDate; //NetworkProviderParam3
NetworkProviderCmd.Parameters.Add("RETURN_VALUE", OdbcType.Int).Direction = ParameterDirection.ReturnValue; //NetworkProviderParam4
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号