-
Contributing Member
ref cursor giving error
hi
i have a table like this--
16:06:01 SQL> select *from ab;
EMPNO EMPNAME JOBNAME
---------- -------------------- ----------
0001 Roger Programer
0002 Miriam Developer
0001 Roger Analyst
0003 Roman Encoder
0002 Miriam Analyst
Elapsed: 00:00:00.01
now i am doing it in this code but an error coming wat i cann't understand--
1 declare
2 type bp is ref cursor return ab%rowtype;
3 v_bp bp;
4 v_tab ab%rowtype;
5 begin
6 open v_bp for select *from ab;
7 fetch v_bp into v_tab;
8 for i in v_tab.first..v_tab.last loop
9 DBMS_OUTPUT.PUT_LINE(v_tab(i));
10 end loop;
11* end;
16:10:00 SQL> /
for i in v_tab.first..v_tab.last loop
*
ERROR at line 8:
ORA-06550: line 8, column 16:
PLS-00302: component 'FIRST' must be declared
ORA-06550: line 8, column 1:
PL/SQL: Statement ignored
-
Contributing Member
Re: ref cursor giving error
sorry
i was wrong sorry to post a silly thing with heavy mistake.
-
Re: ref cursor giving error
Please check the following sample code. ============================ declare type empcurtyp is ref cursor; type namelist is table of emp.ename%type; type sallist is table of emp.sal%type; emp_cv empcurtyp; names namelist; sals sallist; begin open emp_cv for select ename,sal from emp where sal < 3000; fetch emp_cv bulk collect into names, sals; close emp_cv; for i in names.first .. Names.last loop dbms_output.put_line('name = ' || names(i) || ', salary = ' || sals(i)); end loop; end; hope helps you in solving your problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules