create
orreplace
function edubis.getpxfx(v_pxfx in varchar2)
return varchar2 is
pxfx varchar2(
1000);
begin
select wm_concat(b.codename)
into pxfx
from
(select column_value from
table
(splitstr(v_pxfx,
',')
)) a,
up_codelist b
where codekind =
'neuedu_gs_pxfx'
and a.column_value = b.codevalue(+)
;return
(pxfx)
;exception
when no_data_found then
dbms_output.put_line(
'查不到資料。');
return
null
;end getpxfx;
create
orreplace
trigger
"edubis"
.bdh_jfxsjfxxbb
before update
orinsert
ordelete
on edubis.sfxt_jfxsjfxxb
referencing new as new old as old
for each row
declare
err_num number;
err_msg char
(100);
flag number;
error_update exception;
error_insert exception;
error_delete exception;
begin
if updating
--當記錄被修改
then
if(:new.bdhbz <>
'0'and :old.bdhbz =
'1')
then
raise error_update;
endif
;endif;
if inserting
then
select
count(*
)into flag
from htxm_xmrygx b,htxm_xmhtgx c,bdh_sjxz a
where a.htbh=c.htbh and b.xmbh=c.xmbh and b.xybh=:new.xyxyh;
if flag >
0then
-20004
,'資料被本地化模組鎖定');
endif
;endif;
if deleting
then
if(:old.bdhbz =
'1')
then
raise error_delete;
endif
;endif;
exception
when error_update
then
-20003
,'資料被本地化模組鎖定');
when error_insert
then
-20004
,'資料被本地化模組鎖定');
when error_delete
then
-20003
,'資料被本地化模組鎖定');
when others
then
err_num := sqlcode;
err_msg := substr (sqlerrm,1,
100)
; dbms_output.put_line (err_msg)
;end;/
alter
trigger bdh_jfxsjfxxbb disable
ORACLE觸發器 行級觸發器
行級觸發器 本章介紹行級觸發器機制。大部分例子以insert出發器給出,行級觸發器可從insert update delete語句觸發。1 介紹 觸發器是儲存在資料庫已編譯的儲存過程,使用的語言是pl sql,用編寫儲存過程一樣的方式編寫和編譯觸發器。下面在sql plus會話中建立和示例乙個簡單的...
Oracle之函式與觸發器
資料庫中函式包含四個部分 宣告 返回值 函式體和異常處理。1create orreplace function getname sno varchar2 2 return varcharis3 name varchar 12 4begin 5select ename into name from e...
Oracle儲存過程,函式,觸發器
一 儲存過程的定義 1 過程 多次編譯 多次執行 過程實現計算器 declare p1 number 1 p2 number 2 sign varchar2 3 begin if sign then syso p1 p2 elsif sign then syso p1 p2 elsif sign t...