Bank Transfer stored procedure use [Bankinfor]goset ansi_nulls ongoset quoted_identifier ongoalter PROCEDURE [dbo]. [Transfer] (@inAccount int, @outAccount int, @amount float) as declare @totalDeposit float; begin select @totalDeposit =total from account where [email protected]; if @totalDeposit is null & nbsp;begin rollback; print ' transfer out of account does not exist or no deposit in account ' return; end if @totalDeposit < @amount begin rollback; print ' insufficient balance, unable to operate ' return; end update account set [email protected] where [email& nbsp;protected]; update account set [email protected] where [email protected]; print ' Transfer is successful! ' commit; end; serial number generation stored procedure if exists (select 1 from sysobjects where id=object_id (' Getserialno ') and xtype= ' P ') drop proc getserialnogo create procedure [dbo]. [GetserialNo] ( @sCode varchar () ) as begin Declare @sValue varchar, @dToday datetime, @sQZ varchar --This delegate prefix Begin Tran begin Try --Lock the record, a lot of people use lock to lock, Starting here, just execute an update. --in the same thing, after the UPDATE statement is executed, the lock is started Update Serialno set svalue= svalue where [email protected] Select @sValue = svalue from Serialno where [Email prot Ected] Select @sQZ = SQZ from Serialno where [email protected] & No records in nbsp;--factor table, insert initial value if @sValue is null begin & nbsp select @sValue = convert (bigint, CONVERT (varchar (6), GETDATE (), +) + ' 000001 ') &NB Sp update Serialno Set [email protected] WHere [email protected] end else begin --no records in factor table select @dToday = substring (@sValue, 1, 6) --If the dates are equal, add 1 if @dToday = CONVERT (varcha R (6), GETDATE (), select @sValue = convert (varchar), (CONVERT (bigint, @sValue) + 1) else --If the dates are not equal, assign the values first Date, serial number starting from 1 select @sValue = convert (bigint, CONVERT (varchar (6), GETDATE (), + ' 000001 ') Update serialno set svalue [email protected] where [email prote CTED] End Select result = @[email protected] commit Tran end Try begin Catch rollback Tran &nbs p; select result = ' Error ' end Catch end select*from Serialno select convert (varchar (6), GETDATE (), 12) + ' 000001 '
Bank transfer stored procedures and serial number generation stored procedures