oracle----procedure

來源:互聯網
上載者:User

標籤:where   預存程序   1.2   行修改   賦值   ora   rom   type   output   

--初步認識oracle--procedure,

--1.1建立一個完整的procedure,格式如下

create or replace procedure  procedure_name 

is/as

begin

主體

exception

異常處理主體

end procedure ;

procedure_name 是過程名

or replace  則用來覆蓋同過程名的過程的,如果建立的時候,不加or replace 而你建立的過程名又正好存在,就會報錯

 

 參數類型:in

輸入型參數,表示這個參數值可以輸入給過程,供過程使用,是預設類型,不能進行修改。

參數類型:out

輸出型參數,表示這個參數在過程中被賦值,可以提供給過程體以為的部分或環境。

參數類型:in out

輸入輸出型參數 既可以接收傳入的實參值,也可以被子程式修改,可以輸出

 

例如:

create or replace procedure   comunt_num

(in_sex in teaches.sex%type)

 as

out_num number;

begin

if in_sex=‘M‘ then

select count(SEX) into out_num from teachers where sex=‘M‘;

dbms_output.put_line(‘number of male teachers:‘|| out_num);

else

select count(sex) into out_num from teachers where sex=‘F‘;

dbms_output.put_line(‘number of female teachers:‘|| out_number);

end if ;

end conut_num;

1.2儲過程的調用:

execute 預存程序名  參數;

1.3預存程序的刪除:

drop procedure  預存程序名

 

oracle----procedure

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.