mssql发送 post请求??不行吧..楼主的实现可以这样. 前两步可以写个存储过程,第三步也就是加入了更多的逻辑判断,一个道理 insert into PYALOG(...) select @id = scope_identity() --获取新插入的IDif EXISTS(select msg,datetime from PYALOG where id = (select id from WEBALL) and id=@id) begin select @msg = msg,@datetime = datetime from PYALOG where id = @id set @send = 'true' --发送 end else set @send = 'false' --不发送select isnull(@msg,'') as msg,isnull(@datetime,'') as datetime,@send as send 页面通过该存储过程返回的send字段的真或假来判断是否发送post请求..
create trigger paylog_tri on paylog for insert,update as declare @webid varchar(20),@message varchar(50),@datetime datetime,@spid varchar(20) select @webid=webid,@message=message,@datetime=datetime from inserted update weball set weburl=@message+@datetime where webid=@webid if update(paytype) begin select @spid=spid, @message=message,@datetime=datetime from deleted update spall set spurl=@message+@datetime where spid=@spid end go
打击一下楼主在大部分情况下,不要要求数据库做数据存储和处理以外的事情 触发器更加是需要小心,因为触发器执行的时候,触发触发器的语句的事务并没有提交完成,在触发器做其他任务可能导致事务的失败或者长期等待,对性能和功能的影响都可能是致命的。建议,触发器只完成某个简单的数据操作,其他的事务再其他程序完成,比如,你加一个发送表,记录你需要发送的信息,触发器只完成把你的信息添加到这个表,你的程序需要定时检查这个表,有记录就做发送处理,并清除已发送的数据。 按照建议,触发器就简单了: create trigger tr_PYALOG_insert on PYALOG for insert as insert 发送表(WEBURL,MESSAGE,[DATETIME]) select WEBALL.WEBURL,i.MESSAGE,i.[DATETIME] from inserted i,WEBALL where i.WEBID=WEBALL.WEBID gocreate trigger tr_PAYLOG_update on PAYLOG for update as if update (PAYTYPE) insert 发送表(WEBURL,MESSAGE,[DATETIME]) select SPALL.SPURL,i.MESSAGE1,i.[DATETIME1] from inserted i,SPALL where i.SPID=SPALL.SPIDgo
你所说的post传送 原来是比如http://www.xxx.xxx/xxx.xxx?a=11
读出同样id得存在后要变成 比如现在的是22 变成http://www.xxx.xxx/xxx.xxx?a=22
是么
是这样的
SPALL表保存了一个SPID和SPURL
WEBALL保存了一个WEBID和WEBURL当PAYLOG表中的记录变化的时候搜索PYALOG表中的SPID或者WEBID在SPALL表或者WEBALL表中是否有一致的,如果一致的话就把PAYLOG表中的某些值POST到SPURL或者WEBURL这几个网址上面去(其实就是在服务器端打开那几个IE地址)目的也很简单的就是:如果我的数据库一个表记录变化,我如何把变化后的数值即时传到外面的其他的接收页面去(最好不要用在服务器端打开一个刷新页面一直刷新的方式)
前两步可以写个存储过程,第三步也就是加入了更多的逻辑判断,一个道理
insert into PYALOG(...)
select @id = scope_identity() --获取新插入的IDif EXISTS(select msg,datetime from PYALOG where id = (select id from WEBALL) and id=@id)
begin
select @msg = msg,@datetime = datetime from PYALOG where id = @id
set @send = 'true' --发送
end
else
set @send = 'false' --不发送select isnull(@msg,'') as msg,isnull(@datetime,'') as datetime,@send as send 页面通过该存储过程返回的send字段的真或假来判断是否发送post请求..
是不是说一定要建立一个页面一直在取SEND字段呢?
这个页面是不是一直在刷 如果收到了TRUE就发送 如果是FALSE就不要发送了那这样的一个页面怎么取SEND数据呢?取到了后 是不是要传递给这个页面数据让这个页面去发送数据到外面的接收页面
25725864用于数据库ORCALE和SQL SEEVER的学习和探讨欢迎大家的加入
for insert,update
as
declare @webid varchar(20),@message varchar(50),@datetime datetime,@spid varchar(20)
select @webid=webid,@message=message,@datetime=datetime from inserted
update weball set weburl=@message+@datetime where webid=@webid
if update(paytype)
begin
select @spid=spid, @message=message,@datetime=datetime from deleted
update spall set spurl=@message+@datetime where spid=@spid
end
go
触发器更加是需要小心,因为触发器执行的时候,触发触发器的语句的事务并没有提交完成,在触发器做其他任务可能导致事务的失败或者长期等待,对性能和功能的影响都可能是致命的。建议,触发器只完成某个简单的数据操作,其他的事务再其他程序完成,比如,你加一个发送表,记录你需要发送的信息,触发器只完成把你的信息添加到这个表,你的程序需要定时检查这个表,有记录就做发送处理,并清除已发送的数据。
按照建议,触发器就简单了:
create trigger tr_PYALOG_insert
on PYALOG
for insert
as
insert 发送表(WEBURL,MESSAGE,[DATETIME])
select WEBALL.WEBURL,i.MESSAGE,i.[DATETIME]
from inserted i,WEBALL
where i.WEBID=WEBALL.WEBID
gocreate trigger tr_PAYLOG_update
on PAYLOG
for update
as
if update (PAYTYPE)
insert 发送表(WEBURL,MESSAGE,[DATETIME])
select SPALL.SPURL,i.MESSAGE1,i.[DATETIME1]
from inserted i,SPALL
where i.SPID=SPALL.SPIDgo