Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXECUTE recognizes a stored procedure, CALL does not

Tags:

oracle

sqlplus

When I try to run a stored procedure using EXECUTE, the proc runs fine. When I use CALL, I get "ORA-06576: not a valid function or procedure name". I am connecting directly via toad. Why can't I use call?

I have tried both of these Calls:

CALL(BPMS_OWNER.DAILY_PARTITION_NOROTATE('MIP_TEST',5,5,'MIP_TEST_',5,FALSE,TRUE));
CALL BPMS_OWNER.DAILY_PARTITION_NOROTATE('MIP_TEST',5,5,'MIP_TEST_',5,FALSE,TRUE);

The reason I need to use CALL is that our platform parses SQL before we send it to Oracle, which for whatever reason does not support EXECUTE.

like image 506
Stuart Feldt Avatar asked Aug 20 '12 15:08

Stuart Feldt


1 Answers

Simply because call requires that you add parenthesis, for instance, call my_proc()

If I set up a little test:

SQL>
SQL> create or replace procedure test is
  2  begin
  3     dbms_output.put_line('hi');
  4  end;
  5  /

Procedure created.

And run this several different ways you'll see

SQL> exec test
hi

PL/SQL procedure successfully completed.

SQL> call test;
call test
     *
ERROR at line 1:
ORA-06576: not a valid function or procedure name


SQL> call test();
hi

Call completed.

Why do you need to use call? Isn't exec, execute and begin ... end enough?


Based on your update the problem is the booleans, which call doesn't seem to support. Creating yet another small procedure

SQL> create or replace procedure test (Pbool boolean ) is
  2  begin
  3     if Pbool then
  4        dbms_output.put_line('true');
  5     else
  6        dbms_output.put_line('false');
  7     end if;
  8  end;
  9  /

Procedure created.

SQL> show error
No errors.

and running it proves this

SQL> call test(true);
call test(true)
          *
ERROR at line 1:
ORA-06576: not a valid function or procedure name

I don't quite understand your reasoning behind why you can't use exec or execute but assuming these are both off limits why not just use a traditional, anonymous PL/SQL block?

SQL> begin
  2     test(true);
  3  end;
  4  /
true

PL/SQL procedure successfully completed.
like image 144
Ben Avatar answered Sep 28 '22 07:09

Ben