触发器例子
来源:互联网 发布:曹县大集淘宝村地图 编辑:程序博客网 时间:2024/09/21 08:57
create or replace TRIGGER UPDATE_PARTCUT
AFTER INSERT OR UPDATE OR DELETE OF par_no //凡是新增,修改,删除都触发
on PARTCUT
FOR EACH ROW //每一笔资料变更时都触发
begin
if Inserting then //当是新增的时候,在触发器中以OLD表示以前的资料,NEW表示更新的资料
begin
Insert into styleusage(sty_no,par_no,cus_no,difflast) values(:NEW.sty_no,:NEW.par_no,:NEW.cus_no,:NEW.difflast);
end;
end if;
if updating then
begin
update styleusage set sty_no=:NEW.sty_no,par_no=:NEW.par_no,cus_no=:NEW.cus_no,difflast=:NEW.difflast where sty_no=:OLD.sty_no and par_no=:OLD.par_no and cus_no=:OLD.cus_no and difflast=:OLD.difflast;
end;
end if;
if deleting then
begin
delete from styleusage where sty_no=:OLD.sty_no and par_no=:OLD.par_no and cus_no=:OLD.cus_no and difflast=:OLD.difflast;
end;
end if;
end;
以上的ORACLE的格式,其他的数据库有所不同,但原理一样.
过Delphi建立和删除触发器
关键词:建立触发器 Trigger
adocommand1.CommandText:='CREATE TRIGGER trigger_name ON table1 FOR INSERT, UPDATE, DELETE AS insert into table2 (name,old) values('''+edit1.text+''','''+edit2.text+''')';
showmessage(adocommand1.CommandText);
adocommand1.Execute ;
// adoquery1.SQL.Text:='CREATE TRIGGER trigger_name ON table1 FOR INSERT, UPDATE, DELETE AS insert into table2 (name,old) values('''+edit1.text+''','''+edit2.text+''')';
// showmessage(adoquery1.SQL.Text);
button1.Enabled:=false;
button2.Enabled:=true;
showmessage('ok'); //创建触发器
adocommand1.Commandtext:='drop trigger trigger_name';
adocommand1.Execute;
button1.Enabled:=true;
button2.Enabled:=false; //删除触发器
showmessage('ok');
- 触发器例子
- 触发器例子
- 触发器例子
- 触发器例子
- 一个触发器的例子
- 一个触发器的例子
- 两个触发器的例子
- sql触发器的例子。
- 触发器(Trigger) 原理&例子
- oracle数据库触发器例子
- 简单触发器的例子
- 触发器的例子
- 一个触发器的例子
- 触发器小例子!
- 数据库触发器例子
- 触发器的例子
- 带参数触发器例子
- insert 触发器例子
- Ajax实现智能表格(适合B/S模式项目的录入页面)
- C#中的换行代码
- vc的MakeFile工程直接编译驱动
- vs2005兩個非常有用的函數
- 在.net应用程序中使用用户控件 [zt from zz]
- 触发器例子
- 从GMail认识的W3C网页标准和Ajax
- wingrub引导硬盘安装rh9实践(不安装grub的引导)
- 利用apache的proxy-ajp整合apache-2.2.0与tomcat-5.0.30
- IFS应用系统
- Mysql数据库命令
- 温故而知新1——Windows 的访问控制
- 共享,大量Eclipse开发资源
- mysql数据库优化(转)