wdjh.net
当前位置:首页 >> triggEr insErt >>

triggEr insErt

Sql 2008 数据库下的么? CREATE TRIGGER BeforeInsertTest ON student FOR INSERT AS DECLARE @major varchar(20) ; BEGIN -- 取得 专业名. SELECT @major = major FROM INSERTED; -- 更新专业的人数. UPDATE major SET snumber = snumber + 1 ...

做一个新增触发器。 create trigger tr_new on table_name for insert as begin declare @name varchar(10) declare @nameid int select name into @name from inserted select max(nameid) into @nameid from table_name where name @name set ...

直接给出sql 代码吧,其中cno就是代表班级号 create trigger student_trigger on student for insert as if (select cno from inserted) not in (select cno from class) begin rollback transaction end

CREATE TRIGGER t_afterinsert_on_tab1 AFTER INSERT ON tab1 FOR EACH ROW BEGIN if new.tab1_id is not null then update tab1 set aa='bb' where id=new.tab1_id end if; END;

DML触发器有三类: 1, insert触发器; 2, update触发器; 3, delete触发器; 触发器的组成部分: 触发器的声明,指定触发器定时,事件,表名以类型 触发器的执行,PL/SQL块或对过程的调用 触发器的限制条件,通过where子句实现 类型: 应用程...

CREATE OR REPLACE TRIGGER test_trg BEFORE INSERT OR DELETE ON TEST1 BEGIN CASE WHEN inserting THEN inser into test2 value :new; WHEN deleting THEN delete test2 where id=:old.id; END CASE; END;

CREATE OR REPLACE TRIGGER 触发器名称 AFTER INSERT ON A FOR EACH ROW BEGIN INSERT INTO B (字段1,字段2,...,字段n) VALUES(:new.字段1,:new.字段2,...,:new.字段n); END 触发器名称; /

create trigger tr_a on a for insert,update,delere as begin IF EXISTS(SELECT 1 FROM inserted) AND NOT EXISTS(SELECT 1 FROM deleted) BEGIN -- 插入触发. INSERT INTO B SELECT inserted.a FROM inserted; END; IF EXISTS(SELECT 1 FROM i...

CREATE OR REPLACE TRIGGER TRG_aI AFTER INSERT ON a FOR EACH ROW BEGIN INSERT INTO b(x,x)VALUES(x,x)end;

CREATE OR REPLACE TRIGGER TRG_TEST_A BEFORE INSERT ON TEST_A FOR EACH ROW BEGIN IF INSERTING THEN :new.A := nvl(:new.B,0) * nvl(:new.C,0); END IF; END TRG_TEST_A;

网站首页 | 网站地图
All rights reserved Powered by www.wdjh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com