SP-Transfer Funds Code

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Transfer Funds

USE [iBankApr2015]
GO

create proc usp_TransFunds


(
@SenderACID Int,
@ReceiverACID Int,
@TxnAmt Money

)
as

begin

declare @bal Money


select @bal = cbal from AMASTER where ACID = 121

if(@bal >= @TxnAmt)

begin
insert into TMASTER values ( Getdate() , @SenderACID , 'BR1' , 'CW', NULL,
NULL, @TxnAmt , 1)

Update AMASTER
Set Cbal = Cbal - @TxnAmt
Where ACID = @SenderACID

insert into TMASTER values ( Getdate() , @ReceiverACID , 'BR2' , 'CD', NULL ,


NULL , @TxnAmt , 4)

Update AMASTER
Set Cbal = Cbal + @TxnAmt
Where ACID = @ReceiverACID
end

else
begin

print 'You have insufficient Balance'

end
end

Exec usp_TransFunds 101,104,500

select * from AMASTER


select * from TMASTER

You might also like