Hi everyone hope you're doing well. I'm new to PL/SQL and I'm trying to learn 'cursor variable' . I have made and example for myself and everything looks correct and I have no idea why it does not work. my first procedure is

  create or replace procedure p_get_student_detail(s_id  number,
     s_cur out sys_refcursor) AS


     open s_cur for
     select student_name, age from student where student_id = s_id;


and my second procedure in which I'm using the output of the first procedure is :

Create or replace procedure s_print_data(s_id number)


    type ref_cur is ref cursor;
    s_refcur       ref_cur;
    s_student_name student.student_name%type;
    s_student_age  student.age%type;


    p_get_student_detail(s_id, s_refcur);

        fetch s_refcur into s_student_name, s_student_age;
        exit when s_refcur%notfound;
        dbms_output.put_line(s_student_name || s_student_age);
     end loop;

when I try to execute the procedure exec s_print_data (1) I see this error :

ORA - 00900:invalid SQL statement 

I was wondering if you could help me with that. Thanks

  • 2
    It's working fine on 11gr2 (Sql*plus and Oracle Sql Developer)
    – user153556
    Jun 8, 2019 at 9:47
  • 1
    i'm using pl/sql developer and it shows the above mentioned error
    – Pantea
    Jun 8, 2019 at 10:16
  • 2
    You are missing ORA error number and line number. Can you please updatr your question with thst information please? Jun 8, 2019 at 11:05

1 Answer 1


OK I found where the problem is the syntax for calling the procedure is incorrect I have to call the procedure like this :



and everything works fine

  • 1
    exec is an sqlplus command and not an sql command. Some tools understand at least a subset of the sqlplus commands and some do not.
    – miracle173
    Jul 29, 2020 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.