--创建表结构
/*
CREATE TABLE TBL_USER(
USER_ID INTEGER PRIMARY KEY,
UNAME VARCHAR2(20) NOT NULL,
UPWD VARCHAR2(20) NOT NULL,
LAST_MODIFIED DATE
);*/
--1、创建程序包
CREATE OR REPLACE PACKAGE PKG_TBLUSER_UPDATE
AS
G_ID TBL_USER.USER_ID%TYPE;
END PKG_TBLUSER_UPDATE;
/
--2、创建行触发器
CREATE OR REPLACE TRIGGER AFTER_UPD_TBLUSER_ROWTRG
AFTER UPDATE OF UNAME ON TBL_USER
FOR EACH ROW
BEGIN
PKG_TBLUSER_UPDATE.G_ID:=:NEW.USER_ID;
END;
/
--3、创建语句触发器(根据程序包的全局变量,对数据表TBLUSER字段进行更新)
CREATE OR REPLACE TRIGGER AFTER_UPD__TBLUSER_TRG
AFTER UPDATE OF UNAME ON TBL_USER
BEGIN
UPDATE TBL_USER
SET LAST_MODIFIED = SYSDATE
WHERE
USER_ID = PKG_TBLUSER_UPDATE.G_ID;
END;
/