Oracle 的乙個非常好的觸發器例子

2022-01-23 07:46:52 字數 1137 閱讀 7682

create

orreplace

trigger

test_trigger

after

insert

orupdate

of sal or

delete

onemp

foreach row

begin

case

when inserting then

--當事件為insert時,inserting為true

/*:new關鍵字可以獲取新記錄的資料,它只能用於行級觸發器

*/dbms_output.put_line(

'insert into emp values(

'||:new.empno||',

'||:new.ename||',

'||:new.job||',

'||:new.mgr||',

'||:new.hiredate||',

'||:new.sal||',

'||:new.comm||',

'||:new.deptno||')

');when updating then

--當事件為update時,updating為true

dbms_output.put_line('

updating emp which empno=

'||:old.empno||

'to sal:

'||:new.sal);--

:old關鍵字可以獲取舊記錄的資料,它只能用於行級觸發器

when deleting then

--當事件為delete時,deleting為true

dbms_output.put_line('

deleting emp which empno=

'||:old.empno);--

:old關鍵字可以獲取舊記錄的資料,它只能用於行級觸發器

else

null;

endcase

;exception

when dup_val_on_index then

null;

when others then

end test_trigger;

乙個非常好的ORACLE的分頁SQL語句

select from select my table.rownum as my rownum from select yhbh,yhmc from yysf tb yonghxx order by yhbh my table where rownum 20 where my rownum 10 其...

乙個講的非常好的快速排序

講的非常好,反正我是看懂了 package com.shadow.util 快速排序的乙個實現 author shadow public class myquicksort 一次查詢後,將基準數歸位 arr left arr i arr i pivot 繼續處理左邊的,這裡是乙個遞迴的過程 quic...

tinyxml非常好的例項

這個例子對於只想簡單使用xml的使用者來說,非常有學習價值。完整程式 相信具有基本c 知識的人可以明白的 xml檔案內容 xml version 1.0 encoding gb2312 standalone yes resumes num 2 resume name 裕作 gender 男 gend...