请解释一下这个颇让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/12/18 19:44:08
请解释一下这个颇让oracle触发器createorreplacetriggerCUX_CREATE_DOC_SEQbeforeupdateofSTATUSonGL.GL_JE_HEADERSfore

请解释一下这个颇让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.字段,表示更新的值.
这个清楚后,这个也就好理解了.