±±oracle trigger±±
在ORACLE 內部建立觸發器的時候,不能在建立的的基表內引用其他資料,而在建立觸發器的往往需要引用基表的資料,這時候我感覺最好的辦法上:建立檢視!!!!!!!
-- Create table
create table AJCJ_ZAAJDJB
(
BH VARCHAR2(30) not null,
YEAR VARCHAR2(4),
YEAR_NO VARCHAR2(20),
MONTH_NO VARCHAR2(22),
AB VARCHAR2(30),
FA_TIME DATE,
FADD VARCHAR2(30),
BASJ DATE,
DSR1_XM VARCHAR2(30),
DSR1_XB VARCHAR2(30),
DSR1_AGE VARCHAR2(30),
DSR1_ZZ VARCHAR2(30),
DSR1_GGDW VARCHAR2(30),
DSR2_XM VARCHAR2(30),
DSR2_XB VARCHAR2(30),
DSR2_AGE VARCHAR2(30),
DSR2_ZZ VARCHAR2(30),
DSR2_GGDW VARCHAR2(30),
AJQK VARCHAR2(100),
DCJJ VARCHAR2(100),
CLYJ_NR VARCHAR2(50),
CLYJ_TIME_YEAR VARCHAR2(4),
JBR VARCHAR2(30),
DSR1_SFZ VARCHAR2(30),
DSR2_SFZ VARCHAR2(30),
LRRY VARCHAR2(14),
LRDW VARCHAR2(12),
LRSJ DATE,
BDRY VARCHAR2(14),
BDDW VARCHAR2(12),
BDSJ DATE,
XGBS VARCHAR2(2),
JY VARCHAR2(30),
JYBM VARCHAR2(14),
PCS VARCHAR2(14),
CLYJ_TIME_MONTH VARCHAR2(2),
CLYJ_TIME_DAY VARCHAR2(2),
CLYJ_TIME VARCHAR2(30),
BADD DATE
)
create or replace trigger tr_ajcj_zaajdjb_001
before insert on ajcj_zaajdjb
for each row
declare
-- local variables here
year_no number;
month_no number;
begin
select year_nos,month_nos into year_no,month_no
from view_tr_ajcj_zaajdjb_001;-- where substrb(sj,1,4)
=to_char(sysdate,'yyyy');
:new.YEAR_NO:=substrb(:new.jybm,1,12)||year_no;
:new.MONTH_NO:=substrb(:new.jybm,1,12)||month_no;
end tr_ajcj_zaajdjb_001;
create or replace view view_tr_ajcj_zaajdjb_001 as
select a.year_nos,b.month_nos
from
(select nvl(max(substrb(year_no,13,8))+1,
to_char(sysdate,'yyyy')||'0001') year_nos from ajcj_zaajdjb
where substrb(year_no,13,4)=to_char(sysdate,'yyyy')) a,
(select nvl(max(substrb(month_no,13,10))+1,
to_char(sysdate,'yyyymm')||'0001') month_nos from ajcj_zaajdjb
where substrb(month_no,13,6)=to_char(sysdate,'yyyymm')) b
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9879835/viewspace-1000442/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Test Oracle triggerOracle
- Oracle trigger問題Oracle
- oracle trigger 同步資料Oracle
- oracle trigger語法小記(一)Oracle
- oracle trigger觸發器這servererrorOracle觸發器ServerError
- Oracle Instead of Trigger的用法Oracle
- Oracle logon trigger舉例OracleGo
- 禁止oracle表的觸發器triggerOracle觸發器
- Mysql TriggerMySql
- jQuery trigger()jQuery
- sql triggerSQL
- ORA-04091和Compound Trigger(Oracle 11g)Oracle
- oracle 通過trigger解決drop許可權問題Oracle
- Oracle OCP 1Z0 053 Q659(ASM Rebalance Trigger)OracleASM
- 從Oracle資料庫中批量抓取Trigger指令碼的方法Oracle資料庫指令碼
- oracle trigger觸發器審計schema物件的變更ddlOracle觸發器物件
- Oracle 過程(Procedure)、函式(Function)、包(Package)、觸發器(Trigger)Oracle函式FunctionPackage觸發器
- Oracle OCP 1Z0 053 Q148(Trigger&Redifinition)Oracle
- SqlServer 2005 TriggerSQLServer
- python trigger 組合Python
- COMPOUND TRIGGER學習
- logon_triggerGo
- Create a trigger TO monitoring DDL
- WPF TryFindResource typeof Setter Trigger
- trigger 'SYS.GGS_DDL_TRIGGER_BEFORE' is invalid and failed re-validationAI
- Mysql之觸發器triggerMySql觸發器
- /proc/sysrq-trigger檔案
- PLSQL學習-【8trigger】SQL
- Database Logoff Trigger SQLDatabaseGoSQL
- TRIGGER裡的動態SQLSQL
- 禁止DDL執行的trigger
- MySQL入門-- TRIGGER(觸發器)MySql觸發器
- triggerHandler()和trigger()區別
- postman trigger xdebug session in phpstormPostmanSessionPHPORM
- PL/SQL 07 觸發器 triggerSQL觸發器
- 融會貫通學習trigger
- 限制資料庫登陸trigger資料庫
- trigger和物化檢視同步表