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

triggEr insErt

直接给出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

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

create or replace TRIGGER "触发器名称" before insert on 表名 for each row begin select 序列.Nextval into:new.id from dual; -- 实现表ID 自增 end;

做一个新增触发器。 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 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 insert_data after insert on data_table FOR each row begin declare topic_id int; select topic_uuid into topic_id from subtopic_table where subtopic_table.id=new.subtopic_uuid; UPDATE sub_data_sum set datasum=datas...

CREATE TRIGGER UTri_emp_Insert ON emp AFTER INSERT AS BEGIN SET NOCOUNT ON; --当ept里已经存在相关部门编号 update b set counts=counts+1 from inserted a inner join ept b on a.deptno=b.deptno if @@error0 ROLLBACK TRANSACTION --当e...

create trigger 触发器名 on table ICPurchaseEntry for insert as update ICPurchaseEntry set 辅助金额 =金额1 where ID in (select ID from inserted) and 辅助金额 is not null go

做一个新增触发器。 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 ...

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;

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