使用记录集在vb6程序中调用Oracle 9i存储过程时,遇到错误91:对象变量或者没有设置块变量
以下是存储过程
create or replace
PROCEDURE SP_some( P_IN IN VARCHAR2,
P_RECORDSET OUT SYS_REFCURSOR) AS
BEGIN
OPEN P_RECORDSET FOR
SELECT DISTINCT someColumn,
ROUND(TO_NUMBER((TO_DATE(SUBSTR(someTimeStamp,1,15), 'YYYYMMDD HH24MISS')+someInteger/24) - SYSDATE)*24*60) c1,
(TO_CHAR((TO_DATE(SUBSTR(someTimeStamp,1,15), 'YYYYMMDD HH24MISS')+someInteger/24),'DD/MM/YYYY HH24:MI:SS')) c2,
DECODE(someData, 'Y', 'Yes','No') AS someBoolean
FROM t1
WHERE someID = P_IN ;
-- i join more than 5 table here
END ;
我在Oracle SQL Developer计算记录时运行存储过程没有错误, 但如果尝试PUT_LINE值
,则会出现溢出错误DECLARE
i_counter integer;
v_cursor SYS_REFCURSOR;
v_value varchar2(100);
BEGIN
SP_GET_WINDOWTIME(P_IN => 'PleaseWork',
P_RECORDSET => v_cursor);
i_counter := 0;
LOOP
FETCH v_cursor
INTO v_value;
EXIT WHEN v_cursor%NOTFOUND;
i_counter := i_counter + 1;
--DBMS_OUTPUT.PUT_LINE(v_value ); ** Overflow Error encountered
END LOOP;
DBMS_OUTPUT.PUT_LINE('COUNT: ' || i_counter);
CLOSE v_cursor;
END;
调用VB6代码
Set adoConnection = New ADODB.Connection
With adoConnection
.ConnectionString = strConnection$
.Open
End With
'Prepare rscommand and execute stored procedure
Set rsCommand = New ADODB.Command
With rsCommand
.CommandType = adCmdStoredProc
.CommandText = 'SP_some'
End With
rsCommand.Parameters.Append rsCommand.CreateParameter("P_IN", _
adVariant, adParamInput, Len('PleaseWork'), 'PleaseWork')
'rsCommand.Parameters.Append rsCommand.CreateParameter("P_RECORDSET", adIUnknown, adParamOutput, 500) '**not sure required or not
adoRecordSet.CursorLocation = adUseClient
adoRecordSet.Open rsCommand, adoConnection, adOpenKeyset, adLockOptimistic
任何人都可以为我提供一些急需的光线吗?
请帮忙。谢谢。
历史: 在此之前,当使用rsCommand打开记录集时,它会抛出溢出错误。解决方案是使用cursortype和locktype。因此,这个错误。