简体   繁体   English

在 SSIS 2008 的脚本任务中使用 Oracle ODBC 驱动程序时出现问题

[英]Issue using Oracle ODBC driver in Script Task in SSIS 2008

The issue I'm having may not have anything to do with SSIS but I wanted to be thorough.我遇到的问题可能与 SSIS 没有任何关系,但我想彻底。 I am attempting to have essentially the same code (using ODBC) accessing SQL Server, Sybase, and Oracle.我试图让基本相同的代码(使用 ODBC)访问 SQL 服务器、Sybase 和 Oracle。 Everything except Oracle is working (not surprising) but I'm at a loss as to how to resolve this issue.除了 Oracle 之外的所有东西都在工作(并不奇怪),但我不知道如何解决这个问题。

The Oracle driver is the 11.01.00.06 version. Oracle驱动是11.01.00.06版本。 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.我猜这个错误与 cursor 在这种情况下是一个参数有关(对于 SQL 服务器和 Sybase 来说不是这样),我没有考虑到它。 There is no OdbcType for cursor though. cursor 没有 OdbcType。

Any help or suggestions would be appreciated.任何帮助或建议将不胜感激。

The error I am getting is - ERROR [07001] [Oracle][ODBC][Ora]ORA-01008: not all variables bound我得到的错误是 - 错误 [07001] [Oracle][ODBC][Ora]ORA-01008: not all variables bound

Calling code (C#)调用代码 (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.您的 function 请求 3 个参数,但您只传递了 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 MSDN:将参数与 OleDbCommand 或 OdbcCommand 一起使用

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

PS: I can not find OdbcType for cursor PS:我找不到 cursor 的 OdbcType

UPD2 : 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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