限制同时访问存储过程 [英] Restrict simulteneous acces of stored procedure

查看:98
本文介绍了限制同时访问存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程,如下所示:

I have a stored procedure as follow:

insert into callbook
(
callsrno,calldate,customerid,product,modelid,srnumber
,purdate,warranty,dealerid,complaint,enqtype,callfrom
,prefdate,preftime,callstatus,ipaddr1,userid
)
 values 
(
convert(nvarchar(11),@callsrno),@calldate ,@customerid ,@product ,@modelid  ,@srnumber ,
@purdate,@warranty ,@dealerid  ,@complaint,@enqtype ,@callfrom ,
@prefdate,@preftime ,@callstatus ,@ipaddr1 ,@userid 
)



但是有一段时间,一个以上的用户访问了此sp.
和模糊的记录保存在我的数据库中.

因此,我想限制同时访问SP.

Thnx ...



But some time more than one user accessed this sp.
and ambiguous record saved in my database.

So I want to restrict simultaneous access of SP.

Thnx...

推荐答案

歧义记录是什么意思?
我认为您只需要实现引用约束即可:例如,独特的索引约束可以保护您的数据免遭破坏.
因为您正在执行插入操作,所以插入的记录本身不会被损坏,所以我看到的唯一可能性是,如果没有适当的引用约束,它可能会被插入两次.
What do you mean by ambiguous record ?
I think you just need to implement referential contraints: for instance unique index constraints to protect your data from getting corrupted.
Because you are doing an insert the record itself that is being inserted cannot get corrupted, the only possibility I see is that it might be inserted twice if you do not have the proper referential constraints.


如果您使用MS SQL Server 2005或更高版本,则可以使用表提示(例如锁)(排他性-TABLOCKX或简单TABLOCK)来防止在其中同时插入.
http://msdn.microsoft.com/en-us/library/ms187373.aspx [ ^ ]
If you use MS SQL Server 2005 or higher you can use table hints such as locks (exclusive - TABLOCKX, or simple TABLOCK) to prevent simultaneous insert''s in it.
http://msdn.microsoft.com/en-us/library/ms187373.aspx[^]


这篇关于限制同时访问存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆