Bank transfer stored procedures and serial number generation stored procedures

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.