A表有学生基本信息(studntnum xueji 等)
B表是更改学生学籍的,有(studentnum ,xueji 等)
现在我向B表添加一条记录,目的是更改某学生学籍,所以A表中相应学生的xueji项应该和添加在B表中的 xueji一样,用触发器怎么写呢?
|
在A表中创建触发
CREATE TRIGGER [TRIGGER NAME] ON [dbo].[l_p_images] FOR INSERT, UPDATE, DELETE AS 也可以在B表插入数据时,在程序中处理 create or replace trigger B_AFTER_ALL after insert or update or delete on B for each row declare strTableName varchar(32) := 'B'; strValues varchar(256); strPrimaryKeys varchar(256); begin if UPDATING then strValues :='xueji='||:new.xueji; strPrimaryKeys := 'STUDENTNUM='||:new.STUDENTNUM; update A set strValues where strPrimaryKeys; end if; exception when others then null; end B_AFTER_ALL; / |