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

发布于 2024-11-24 11:55:28 字数 1589 浏览 3 评论 0原文

我遇到的问题可能与 SSIS 没有任何关系,但我想彻底解决。我试图使用基本相同的代码(使用 ODBC)访问 SQL Server、Sybase 和 Oracle。除了 Oracle 之外的所有内容都在工作(并不奇怪),但我不知道如何解决这个问题。

Oracle驱动程序是11.01.00.06版本。我能够成功连接到实例,但调用(对函数)失败。我猜测该错误与游标在本例中是一个参数有关(对于 SQL Server 和 Sybase 来说并非如此),并且我没有考虑它。但游标没有 OdbcType。

任何帮助或建议将不胜感激。

我收到的错误是 - 错误 [07001] [Oracle][ODBC][Ora]ORA-01008: 并非所有变量都绑定

调用代码 (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();

过程参数

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心在旅行 2024-12-01 11:55:28

您的函数请求 3 个参数,但您只传递 2 个。

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

UPD

MSDN:使用带有 OleDbCommand 或 OdbcCommand 的参数

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

PS:我找不到光标

UPD2 的 OdbcType:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文