0
我對錶和視圖創建有以下代碼。dbms_sql.to_cursor_number - 爲SYS_REFCURSOR獲取無效光標錯誤
create table test_company
(
comp_id number
, comp_name varchar2(500)
)
;
insert into test_company values(1, 'CompanyA');
insert into test_company values(2, 'CompanyB');
insert into test_company values(3, 'CompanyC');
create or replace view test_company_view as select * from test_company;
而我的遊標測試有以下代碼。但dbms_sql.to_cursor_number
遇到錯誤ORA-01001: invalid cursor
set serveroutput on;
declare
reader test_company_view%ROWTYPE;
datacursor SYS_REFCURSOR;
v_cursor_id number;
begin
open datacursor for select * from test_company_view;
v_cursor_id := dbms_sql.to_cursor_number(datacursor); -- ERROR: invalid cursor
loop fetch datacursor into reader;
exit when datacursor%NOTFOUND;
dbms_output.put_line(reader.comp_id);
end loop;
close datacursor;
end;
我做了什麼錯?感謝您的幫助!
我試過strongly-typed REF CURSOR
和weakly-typed REF CURSOR
但他們得到了同樣的錯誤。
非常感謝!我沒有詳細閱讀文檔,但經過多次試驗後我發現了這種行爲。 –