Oracel 10g 中 创建触发器时 临时表是???
CREATE OR REPLACE TRIGGER receivedBook_insert_update
BEFORE INSERT OR UPDATE
ON t_leoa_ReceivedBook
FOR EACH ROW
BEGIN
DECLARE LandNo VARCHAR2(100)
SELECT t_leoa_ReceivedBook.LandInfo_LandNo FROM Dual -- 临时表
IF LandInfo_LandNo !:= NULL THEN
SELECT LandNo := LandInfo_LandNo FROM t_leoa_BookFlow
WHERE t_leoa_ReceivedBook.LandInfo_LandNo
IF LandNo !:= NULL THEN
UPDATE t_leoa_BookFlow SET LandInfo_LandNo := LandNo+1 WHERE
Flow_ID := (SELECT FLOW_ID FROM t_leoa_BookFlow WHERE LandInfo_LandNo := LandNo)
ELSIF
INSERT INTO t_leoa_BookFlow VALUES(1,FLOW_CURCIRINDEX,FLOW_RECTIME,FLOW_APPLYTIME,
FLOW_REASEARCHTIME,FLOW_FIRSTAUDITTIME,FLOW_BULLETINTIME,FLOW_LASTAUDITTIME,FLOW_REGISTERTIME,
FLOW_SHANZHENGTIME,FLOW_ISSUELANDCERTIFYTIME,FLOW_FTPFOLDERNAME,FLOW_FLAG,LandInfo_LandNo)
END BEFORE ReceivedBook_insert_update;
调试一天还出错 麻烦高手 帮帮忙 多谢啦!!!
问题补充:
---------收件单触发器
CREATE OR REPLACE TRIGGER tib_Leoa_ReceivedBook
BEFORE INSERT OR UPDATE ON t_Leoa_ReceivedBook
FOR EACH ROW
DECLARE
land_no VARCHAR2(50); --存储地籍号
del_flag Integer; --检测删除标志
total Integer; --存储、判断获取值
rec_date date; --记录收件时的日期
add_value integer; --当前操作需要增加或者删除的值
BEGIN
/*赋予默认值*/
del_flag := 0;
land_no := '';
add_value := 1; --根据对应环节不同该值而不同
/*从临时表DUAL获取删除标志存储在del_flag 中*/
SELECT :new.Received_Flag INTO del_flag FROM DUAL;
/*从临时表DUAL获取的地籍号存储在land_no中,*/
SELECT :new.Landinfo_Landno INTO land_no FROM DUAL;
/*从临时表DUAL获取的收件日期存储在rec_date中,*/
SELECT :new.Received_ReceivedTime INTO rec_date FROM DUAL;
/*通过LandNo从流程表中检测流程信息表中是否含有该条记录的流程信息*/
/*flow_flag=-1表示该条记录在流程信息表已被逻辑删除,不再参与实际事务*/
SELECT COUNT(*) INTO total FROM t_leoa_BookFlow t
WHERE t.LandInfo_LandNo = land_no AND t.flow_flag <> -1;
/*如果在流程信息表中有关于该条记录的流程信息*/
IF total >= 1 THEN
/*开始判断当前的操作是INSERT还是UPDATE*/
IF inserting THEN
UPDATE t_leoa_BookFlow SET Flow_ProcessValue = Flow_ProcessValue + add_value
WHERE LandInfo_LandNo = land_no AND Flow_flag <> -1;
ELSE
/*如果是UPDATE操作*/
IF(updating and (del_flag = -1)) THEN
UPDATE t_leoa_BookFlow SET Flow_ProcessValue = Flow_ProcessValue - add_value
WHERE LandInfo_LandNo = land_no AND Flow_flag <> -1;
END IF;
END IF;
ELSE
/*如果流程信息表中不存在当前的记录*/
INSERT INTO t_leoa_BookFlow
values(0,add_value,null,rec_date,null,null,null,null,null,null,null,null,null,del_flag,land_no);
END IF;
END;
借我一生
|
初学一级
|
园豆:
93
提问于:2010-04-28 17:41