Oracle中執行儲存過程call和exec區別

2021-09-29 07:10:45 字數 716 閱讀 5287

在sqlplus中這兩種方法都可以使用: 

exec pro_name(引數1..); call pro_name(引數1..); 

區別: 

1. 但是exec是sqlplus命令,只能在sqlplus中使用;call為sql命令,沒有限制. 

2. 儲存過程沒有引數時,exec可以直接跟過程名(可以省略()),但call則必須帶上().  

sql** 

sql> --建立過程 插入資料   

sql> create or replace procedure pro1 is     

2  begin --執行部分   

3        insert into mytest values('張三', 'mm');     

4  end;     

5  /       

procedure created  

sql> exec pro1;       

pl/sql procedure successfully completed  

sql> call pro1;       

call pro1       

ora-06576: 不是有效的函式或過程名      

sql> call pro1();       

method called 

總結:在呼叫過程時,應該養成使用call,且要帶上()的習慣。

Ant中執行oracle儲存過程

同樣的oracle dll指令碼 declare c int begin select count into c from user tables where table name upper activestarttimes if c 1 then execute immediate drop t...

Oracle儲存過程執行許可權

預設情況下,在呼叫儲存過程使用者的角色是不起作用的,即在執行儲存過程時只有public許可權。所以如果被呼叫的儲存過程中如果有execute immediate create table.語句,將會引發ora 01031 insufficient privileges錯誤。儲存過程分為兩種,即dr ...

ORACLE 定時執行儲存過程

推薦用dbms scheduler方式更好 2012 11 19注 查詢 select job,broken,what,interval,t.from user jobs t job job的唯一標識,自動生成的 broken 是否處於執行狀態,n 執行 y 停止 what 儲存過程名稱 next ...