Search code examples
oracle-databasestored-proceduresoracle-sqldeveloperexec

SQLDeveloper execute procedure with parameters


I'm struggling to find a way to execute a procedure that has a SYS_REFCURSOR I found different ways and it appears is easier in sqlplus but I wanted to do it through a query in sqldeveloper

The query takes 3 parameters and has a 4th that is a SYS_REFCURSOR

procedure_example(var1 number,var2 varchar2,var3 varchar2,result out sys_refcursor)

How would I execute something like this in SQLDEVELOPER?


Solution

  • As this is a procedure with an OUT parameter, you'll have to use another PL/SQL block which has DECLARE section (so that you'd have "something" to accept what your procedure returns).

    declare
      l_rc sys_refcursor;
    begin
      procedure_example(var1   => 1,
                        var2   => 2,
                        var3   => 3,
                        result => l_rc);
    end;
    /
    

    (You'd pass meaningful values to IN parameters, of course.)


    Another option is to declare a variable, use it while executing the procedure and print its contents. For example (based on Scott's sample schema):

    enter image description here