建立更新的儲存過程,輸錯訂單號顯示訂單不存在:
create
or replace procedure
upd_shipdate
(orderid number,shipdate date)
ise_no_row
exception;
begin
update ord set v_shipdate=shipdate where v_orderid=orderid;
if sql%notfound then
raise e_no_row;
endif;
exception
when e_no_row
then
end upd_shipdate;
新增的儲存過程:
create
or replace procedure
add_ord
( v_orderid number,
v_orderdate date,
v_custid number,
v_shipdate date,
v_total number)is
e_integrity
exception ;
e_shipdate exception ;
pragma exception_init(e_integrity,-2291);
begin
if v_shipdate >= v_orderdate then
insert into ord values
(v_orderid,
v_orderdate,
v_custid,
v_shipdate,
v_total
) ;else
raise e_shipdate ;
endif;
exception
when dup_val_on_index then
when e_integrity then
when e_shipdate then
end;
刪除儲存過程:
create
or replace procedure
del_ord
(v_orderid number)
ise_integrity
exception;
pragma exception_init(e_integrity,-2292);
begin
delete from ord where v_orderid=v_orderid;
if sql%notfound then
endif;
exception
when e_integrity then
end;
pl/sql塊:
declare vid number(20);
begin
select v_custid into vid from ord where v_orderid=&no;
dbms_output.put_line('顧客id:'||vid); //注意格式;&no為sql/plus替代變數
exception //異常提示
when no_data_found then
dbms_output.put_line('請輸入正確的雇員號');
end;
oracle 儲存過程例1
一 功能設計 開發目標研究生招生系統,要求設計pl sql程式對考生的成績資料進行處理,處理的邏輯是根據每門專業課的最低分數線和總分的最低分數線自動將考生歸類為錄取考生 調劑考生 落選考生。為此設計2個資料表,graduate資料表存放考生成績,result資料表存放處理結果,pl sql程式完成的...
ORACLE 儲存過程 練習七 陣列專題
寫在前面的廢話 由於工作需要經常用到 oracle儲存過程 其中陣列是不可避免的一組成元素.那麼讓我們來體會一下 oracle儲存過程的陣列到低是如何使用的.首先陣列是乙個資料型別 type 需要如下語句進行建立和宣告.create orreplace type myvarray list as v...
儲存過程練習
insert into person values 1 zdw zdw test1 insert into person values 2 test test test2 insert into person values 3 admin admin admin3 在儲存過程中使用子查詢 creat...