ASP

本类阅读TOP10

·asp常用数据库连接方法和技巧
·无组件生成BMP验证码
·一些常用的辅助代码 (网络收藏)
·JavaScript实现的数据表格:冻结列、调整列宽和客户端排序
·VisualStudio.NET_2003及其 MSDN 下载地址
·ASP模拟MVC模式编程
·图片以二进制流输出到网页
·MD5加密算法 ASP版
·ASP.NET编程中的十大技巧
·改进 ASP 的字符串处理性能

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
关于view的触发器的例子.

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

/*create table UserTable
(
    UserId       uniqueidentifier NOT NULL ROWGUIDCOL, -- 唯一标识
    Name          nvarchar(60)  NULL,  -- 名

   age     int NULL DEFAULT 0 check(age>20) ,-- 年龄
   
    address     nvarchar(25) NULL  --地址
)*/
go

create table LogTable1
(
name  nvarchar(60) null,
age int
)
go
create table LogTable2
(
name  nvarchar(60) null,
age int
)

go
insert LogTable1 values ( 't11',30)

insert LogTable1 values ( 't12',40)

insert LogTable1 values ( 't13',50)

insert LogTable2 values ( 't21',130)

insert LogTable2 values ( 't22',140)

insert LogTable2 values ( 't23',150)
insert LogTable2 values ( 't24',160)

select * into logAll from logtable1 union select * from logtable2


go
--create  view
Create view logView
as
select *  from logtable1 union select * from logtable2

--create trigger of delete in view
create trigger logView_delete on logView instead of delete
as
begin
delete logAll where name in (select name from deleted)
end
go

--create trigger of insert in view
create trigger logView_insert on logView instead of insert
as
begin
insert logAll select * from inserted
end
go


--create trigger of update in view
create trigger logView_update on logView instead of update
as
begin
 set nocount off
 if not exists(select * from inserted) return
 
 declare @name varchar(20)
        declare @oldname varchar(20)
 declare @age int

 select @name = name,@age=age from inserted
        select @oldname=name from deleted

         update logtable1 set [email protected],[email protected] where [email protected]
 update logtable2 set [email protected],[email protected] where [email protected]
 /*
 
 if @namer is null and @age is null
 begin
     raiserror ( 1074008065, 16, 127 ) with nowait, seterror
     return
 end

 if(UPDATE(name))-
 begin
      EXEC p_GetName
 end
 */


end


--test
delete logview where name='t11'

insert logview values('v1',100)


update logView set name='t1212',age=10000 where name='t12'

 




相关文章

相关软件