我遇到的问题可能与SSIS没有任何关系,但我想要彻底。我试图使用访问SQL Server,Sybase和Oracle的相同代码(使用ODBC)。除了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
答案 0 :(得分:0)
您的函数请求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
NetworkProviderParam0 = NetworkProviderCmd.Parameters.Add("@pRESULT_CURSOR", OracleType.Cursor);
NetworkProviderParam0.Direction = ParameterDirection.InputOutput;
P.S。:我找不到游标的OdbcType
<强> 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