Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 冲浪宝典 > 网络资源 > 一个触发器事例
【标  题】:一个触发器事例
【关键字】:
【来  源】:http://blog.csdn.net/hbtsbht/archive/2007/02/11/1507871.aspx

一个触发器事例

Your Ad Here
update bankcard set maney = maney -5000 where id = 1
//测试用的sql语句
CREATE TRIGGER 触发器名称 ON [dbo].[bankCard] 
FOR INSERTUPDATEDELETE 
AS
if update(maney) //列名
declare @firstManey int
declare @secondManey int 
declare @fristCardID int 
declare @secondCardID int 
select @firstManey = maney from inserted
select @secondManey = maney from deleted
select @fristCardID = CardID from inserted
select @secondCardID = CardID from deleted

update bankCard set maney =( maney - (@secondManey  - @firstManey)) where CardID = @secondCardID 


数据库

CardID 主键 int 卡号
maney  int 金额


on 后面是标名字 update 动作 inserted是update语句执行前的虚拟表 deleted是update语句修改以后的虚拟表

防止表单重复提交的新方法(action拦截法)。:【上一篇】
ORACLE 11g新特性中文版:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • SQL的同步
  • Apache下用rewrite实现动态二级域名解析
  • c++ 的11个要点基础知识[转载]
  • ASP.NET升级能力探讨(一)
  • 养成好的编程习惯
  • Oracle for Linux vs. Oracle for NT
  • 文件夹快速浏览免费小软件: KO Approach
  • Linux进入单用户模式
  • 试试Cashfiesta帮你赚美元!
  • IE异步可插入协议扩展
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.