This question has suggested answer(s)

Bind Variable "cursorMemoria" is NOT DECLARED

Follow / 9 Jul 2018 at 5:05am

hello,

I have the next example: 

create or replace procedure listaEmpleados(cursorMemoria OUT SYS_REFCURSOR)
as
BEGIN
open CURSORMEMORIA for select * from HR.EMPLOYEES;
DBMS_OUTPUT.ENABLE(1000000);
END;

set AUTOPRINT on;

VARIABLE cursorMemoria SYS_REFCURSOR;
EXECUTE listaEmpleados(:cursorMemoria);

But I have the Bind Variable "cursorMemoria" is NOT DECLARED.   Please could you help me.  Thank you.

Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |

VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
BINARY_FLOAT | BINARY_DOUBLE ] ]

Bind Variable "cursorMemoria" is NOT DECLARED
anonymous block completed

Replies

All Replies
  • Suggested Answer
    Follow / 10 Jul 2018 at 2:00pm

    Try this. This is working

    create or replace procedure listaEmpleados(cursorMemoria OUT SYS_REFCURSOR)
    as
    BEGIN
    open CURSORMEMORIA for select * from EMPLOYEES;
    DBMS_OUTPUT.ENABLE(1000000);
    END;

    set AUTOPRINT on;

    set echo on;

    DECLARE
       cursorMemoria SYS_REFCURSOR;
    BEGIN   
      listaEmpleados(cursorMemoria);
    END;

  • Follow / 19 Jul 2018 at 1:46pm

    Hi Antoine_mc1,

    This line:

    VARIABLE cursorMemoria SYS_REFCURSOR;

    should be this:

    VARIABLE cursorMemoria REFCURSOR;

    You have the wrong variable type because when I try typing in your example code, I get this:

    SQL> var badList sys_refcursor;


    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
    VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
    NVARCHAR2 (n) | CLOB | NCLOB | BLOB | BFILE
    REFCURSOR | BINARY_FLOAT | BINARY_DOUBLE ] ]

    But it works fine with just REFCURSOR.

    --

    Cheers,

    Norm. [TeamT]