EXECUTE recognizes a stored procedure, CALL does not

99封情书 提交于 2019-12-21 21:31:05

问题


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.


回答1:


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.


来源:https://stackoverflow.com/questions/12040261/execute-recognizes-a-stored-procedure-call-does-not

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!