Det er ikke tilladt at bruge markørvariabler i for
cursor loop (FOR i IN myCursor
). Du skal eksplicit hente fra markørvariablen én række ad gangen ved at bruge FETCH INTO
sætning og almindelig loop-sætning for eksempel eller brug FETCH BULK COLLECT INTO
at udfylde en samling. For eksempel:
SQL> declare
2 TYPE t_clientID_nt IS TABLE OF dual%rowtype;
3 clientID_nt t_clientID_nt;
4
5 l_cur sys_refcursor;
6
7 procedure OpenAndPopulateCursor(p_cur in out sys_refcursor) is
8 begin
9 open p_cur for
10 select *
11 from dual;
12 end;
13
14 begin
15 OpenAndPopulateCursor(l_cur);
16
17 if l_cur%isopen
18 then
19 fetch l_cur bulk collect into clientID_nt;
20 end if;
21
22 dbms_output.put_line(concat( to_char(clientID_nt.count)
23 , ' record(s) has/have been fetched.'));
24 end;
25 /
1 record(s) has/have been fetched.
PL/SQL procedure successfully completed