编辑:
1970-01-01
开始一个事务:
sqlexec(nhandle,"begin tran")&&开始一个事务,事实上sqlexec()中的第二个参数中的操作都是被发送到sql server执行的。这样也就可以理解存储过程的一个优点,因为存储过程只要发送一个调用语句给服务器,而如果将这些语句全部写在VFP端,则带来的网络传送量必然很多,客户端越多,造成网络阻塞的可能就越大。回到事务上来。
sqlexec(nhandle,"insert into tablename value s()")
sqlexec(nhandle,"if @@error<>0")
sqlexec(nhandle,"begin")
sqlexec(nhandle,"rollback tran")
sqlexec(nhandle,"return")
sqlexec(nhandle,"end")
sqlexec(nhandle,"delete from tablename where ")
sqlexec(nhandle,"if @@error<>0")
sqlexec(nhandle,"rollback tran")
sqlexec(nhandle,"else")
sqlexec(nhandle,"commit tran")
当然在vfp8中可以写成text endtext的形式更加直观
不过我个人感觉,有事务处理的处理还是最好写成过程。例在服务器上建立过程
create proc procname
as
begin tran
insert into tablename value s()
if @@error<>0
begin
rollback tran
return
end
delete from tablename where
if @@error<>0
rollback tran
else
commit tran
在vfp端sqlexec(nhandle,"exec procname")
精品学习网为您筹备的2016计算机二级VFspt使用方法到这里就结束了,机会稍纵即逝,你还在等什么呢?
相关推荐:
标签:计算机等级考试
精品学习网(51edu.com)在建设过程中引用了互联网上的一些信息资源并对有明确来源的信息注明了出处,版权归原作者及原网站所有,如果您对本站信息资源版权的归属问题存有异议,请您致信qinquan#51edu.com(将#换成@),我们会立即做出答复并及时解决。如果您认为本站有侵犯您权益的行为,请通知我们,我们一定根据实际情况及时处理。