请解释一下这个颇让oracle触发器create or replace trigger CUX_CREATE_DOC_SEQbefore update of STATUS on GL.GL_JE_HEADERSfor each rowwhen (old.status 'P'and new.CURRENCY_CODE 'STAT' AND NEW.ACTUAL_FLAG = 'A')declareVPREFLEX varchar2(20);VSEQ

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/25 20:19:04
请解释一下这个颇让oracle触发器create or replace trigger CUX_CREATE_DOC_SEQbefore update of STATUS on GL.GL_JE_HEADERSfor each rowwhen (old.status 'P'and new.CURRENCY_CODE 'STAT' AND NEW.ACTUAL_FLAG = 'A')declareVPREFLEX varchar2(20);VSEQ
xU[SF+ߛ!uG0#!u,*\vdim<4P.!I I&&LN)1N$SBV8Ld/=E9[;joi`n!hQfu~kxN͈ i-j*a_TᬮL*h6QR%. J/ <,2J<eOSSą>ZwϷ:)E7 TԮbM"H PDU3I* ̈́aE7x4+Ѣ?w9CRaFP).#@0{p.^=I.!9<ߔRh۽aiH9Ht>*G}>FGoזV\~V9|5j# C.!-3Q=EtXԙx1oϤCn՛$v$$:m>#'cs rrįhN~'6i5꾿.Ŝ+ɟsG؏12y$) j5IX&(ǝx#aLwt\ fR_!E++[G{b83>|vd4?mχ7%WgoD1Ʌ 7ve.mRtw3 7\g^^2BV _D%^(\~=^;?$vGP$AgԺG%9yٿ=vgLkXP /

请解释一下这个颇让oracle触发器create or replace trigger CUX_CREATE_DOC_SEQbefore update of STATUS on GL.GL_JE_HEADERSfor each rowwhen (old.status 'P'and new.CURRENCY_CODE 'STAT' AND NEW.ACTUAL_FLAG = 'A')declareVPREFLEX varchar2(20);VSEQ
请解释一下这个颇让oracle触发器
create or replace trigger CUX_CREATE_DOC_SEQ
before update of STATUS on GL.GL_JE_HEADERS
for each row
when (old.status 'P'
and new.CURRENCY_CODE 'STAT' AND NEW.ACTUAL_FLAG = 'A'
)
declare
VPREFLEX varchar2(20);
VSEQ number;
Orgid number;
Sobid number;
begin
SELECT GJB.ORG_ID
INTO ORGID
FROM GL_JE_BATCHES GJB
WHERE GJB.JE_BATCH_ID = :NEW.JE_BATCH_ID;
Sobid := :NEW.SET_OF_BOOKS_ID;
------------------------------------------------------------------
关键是::NEW 和 :old
IF :new.STATUS = 'P' THEN
select next_je_sequence
into VSEQ
from cux_gl_je_sequence
where SET_OF_BOOKS_ID = :NEW.SET_OF_BOOKS_ID and ORG_ID = Orgid and
PERIOD_NAME = :NEW.PERIOD_NAME
/*for update of next_je_sequence*/;
:new.doc_sequence_value := VSEQ;
update cux_gl_je_sequence
set next_je_sequence = next_je_sequence + 1
where SET_OF_BOOKS_ID = :NEW.SET_OF_BOOKS_ID and ORG_ID = Orgid and
PERIOD_NAME = :NEW.PERIOD_NAME;
END IF;
exception
when no_data_found then
insert into cux_gl_je_sequence
(set_of_books_id,org_id,period_name,next_je_sequence)
values
(:NEW.SET_OF_BOOKS_ID,orgid,:new.period_name,2);
:new.doc_sequence_value := 1;
end;

请解释一下这个颇让oracle触发器create or replace trigger CUX_CREATE_DOC_SEQbefore update of STATUS on GL.GL_JE_HEADERSfor each rowwhen (old.status 'P'and new.CURRENCY_CODE 'STAT' AND NEW.ACTUAL_FLAG = 'A')declareVPREFLEX varchar2(20);VSEQ
触发时间是更新之前,因为是更新,所以涉及到更新前的值和更新的值,这样对于一行数据,就有两个前后的数据.:OLD.字段,表示更新之前原来的值,而:NEW.字段,表示更新的值.
这个清楚后,这个也就好理解了.