0

我需要从 Oracle 存储过程中检索数据。存储过程如下:

CREATE OR REPLACE PROCEDURE ATP_CONTRACT_SP
(
p_ContractNumber   IN   VARCHAR2,
p_ResultSet        OUT  ATPSP.cursorType
)
AS
BEGIN
OPEN p_ResultSet FOR
with t1 as (
select sc.c_ntp_no as ATP#, case when length(sc.c_proj_code) = 6 
...
from agt),
mt2 as (
select * from mt union select * from modagt
order by 3, 1 desc)
select mt2.atp#, mt2.llw#, '' as School, mt2.c_cont_type, mt2.approved, mt2.phase,          mt2.award, mt2.amendment,
mt2.totalaward, mt2.ATPApprvdOn,  mt2.rfp, mt2.balance, mt2.ctd_rfp
from mt2;
END;

访问代码如下:

    Dim atpNumber As ADODB.Parameter, llwNumber As ADODB.Parameter, schoolString As ADODB.Parameter, _
    contractTypeString As ADODB.Parameter, approvedBool As ADODB.Parameter, _
    phaseString As ADODB.Parameter, awardNumber As ADODB.Parameter, _
    amendmentNumber As ADODB.Parameter, totalAwardNumber As ADODB.Parameter, _
    ATPApprovedOnDate As ADODB.Parameter, rfpNumber As ADODB.Parameter, _
    balanceNumber As ADODB.Parameter, ctd_rfpString As ADODB.Parameter

    Dim conn As ADODB.Connection
    Dim connString As String
    connString = "Driver={Microsoft ODBC for Oracle};DSN=xxx;UID=xxx;PWD=xxx;SERVER=xxx"
    Dim rsCommand As ADODB.Command
    Set rsCommand = New ADODB.Command

   Set atpNumber = rsCommand.CreateParameter("atp#", adVarChar, adParamOutput, 20)
   Set llwNumber = rsCommand.CreateParameter("llw#", adVarChar, adParamOutput, 20)
   Set schoolString = rsCommand.CreateParameter("School", adVarChar, adParamOutput, 20, Null)
   Set contractTypeString = rsCommand.CreateParameter("c_cont_type", adVarChar, adParamOutput, 20)
   Set approvedBoolString = rsCommand.CreateParameter("approved", adVarChar, adParamOutput, 2)
   Set phaseString = rsCommand.CreateParameter("phase", adVarChar, adParamOutput, 35)
   Set awardNumber = rsCommand.CreateParameter("award", adNumeric, adParamOutput)
   Set amendmentNumber = rsCommand.CreateParameter("amendment", adNumeric, adParamOutput)
   Set totalAwardNumber = rsCommand.CreateParameter("totalaward", adNumeric, adParamOutput)
   Set ATPApprovedOnDate = rsCommand.CreateParameter("ATPApprvdOn", adDate, adParamOutput)
   Set rfpNumber = rsCommand.CreateParameter("rfp", adNumeric, adParamOutput)
   Set balanceNumber = rsCommand.CreateParameter("balance", adNumeric, adParamOutput)
   Set ctd_rfpString = rsCommand.CreateParameter("ctd_rfp", adVarChar, adParamOutput, 255)

   rsCommand.Parameters.Append atpNumber
   rsCommand.Parameters.Append llwNumber
   rsCommand.Parameters.Append schoolString
   rsCommand.Parameters.Append contractTypeString
   rsCommand.Parameters.Append approvedBoolString
   rsCommand.Parameters.Append phaseString
   rsCommand.Parameters.Append awardNumber
   rsCommand.Parameters.Append amendmentNumber
   rsCommand.Parameters.Append totalAwardNumber
   rsCommand.Parameters.Append ATPApprovedOnDate
   rsCommand.Parameters.Append rfpNumber
   rsCommand.Parameters.Append balanceNumber
   rsCommand.Parameters.Append ctd_rfpString

   Set rsRecords = rsCommand.Execute

rsCommand.Execute线有错误提示:Multiple-step OLEDB operation generated errors。我已经为此工作了两天,需要完成这项工作。我对技术挑战很感兴趣。

我哪里会出错?

请提醒我任何问题。

4

1 回答 1

0

1 你从不设置 rsCommand 属性来指定 Oracle 过程

2 它返回一个记录集,而不是一系列参数

您需要 1 个输入参数 p_contractnumber advarchar 您需要 1 个输出参数 P_resultset

于 2013-07-23T15:34:20.777 回答