sql server儲存過程的條件判斷和事務管理
阿新 • • 發佈:2019-01-24
CREATEprocedure vipProcess
as
begin
if (MONTH(getdate())=7)
begin
begintransaction
update vipPoint set currentStatus=1where baseStatus=1and point>1000
update vipPoint set currentStatus=0where baseStatus=1and point<1000
update vipPoint set currentStatus=1where baseStatus =0and point>1500
update vipPoint set currentStatus=0where baseStatus=0and point<1500
/**update vipPoint set point=0**/
update vipPoint set point=10000000000000000000000000000
if (@@error<>0)
begin
print('rollback transaction')
rollbacktransaction
return0;
end;
committransaction
end;
end;
GO
as
begin
if (MONTH(getdate())=7)
begin
begintransaction
update vipPoint set currentStatus=1where baseStatus=1and point>1000
update vipPoint set currentStatus=0where baseStatus=1and point<1000
update vipPoint set currentStatus=1where baseStatus
update vipPoint set currentStatus=0where baseStatus=0and point<1500
/**update vipPoint set point=0**/
update vipPoint set point=10000000000000000000000000000
if (@@error<>0)
begin
print('rollback transaction')
rollbacktransaction
return0;
committransaction
end;
end;
GO