Results 1 to 3 of 3

Thread: ref cursor giving error

  1. #1
    Contributing Member
    Join Date
    Apr 2006

    ref cursor giving error

    i have a table like this--

    16:06:01 SQL> select *from ab;

    ---------- -------------------- ----------
    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

  2. #2
    Contributing Member
    Join Date
    Apr 2006

    Re: ref cursor giving error

    i was wrong sorry to post a silly thing with heavy mistake.

  3. #3
    Join Date
    Jun 2007

    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
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.