📄 ת
字号:
create procedure turn
@type1 varchar(50),
@type2 varchar(50),
@card_no1 char(13),
@card_no2 char(13),
@amount float,
@flag integer
as
begin transaction
/* 计算存款的利息*/
update fund_bill
set fortune_amount=fortune_amount+fortune_amount*0.005*(datediff(day,Deposit_date,getdate()))
where card_type=@type1 and card_no=@card_no1
if @@Error<>0 goto pro
update fund_bill
set fortune_amount=fortune_amount+fortune_amount*0.005*(datediff(day,Deposit_date,getdate()))
where card_type=@type2 and card_no=@card_no2
if @@Error<>0 goto pro
/* 转账*/
update fund_bill
set fortune_amount=fortune_amount-@amount-@amount*0.02,deposit_date=getdate()
where card_type=@type1 and card_no=@card_no1 and @flag=1
if @@Error<>0 goto pro
update fund_bill
set fortune_amount=fortune_amount-@amount-@amount*0.05,deposit_date=getdate()
where card_type=@type1 and card_no=@card_no1 and @flag=0
if @@Error<>0 goto pro
update fund_bill
set fortune_amount=fortune_amount+@amount,deposit_date=getdate()
where card_type=@type2 and card_no=@card_no2
if @@Error<>0 goto pro
commit transaction
return 0
pro:
Rollback Transaction
return 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -