Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:17:59+00:00 2026-05-24T00:17:59+00:00

I am doing a financial application in which I am expecting a data concurrency

  • 0

I am doing a financial application in which I am expecting a data concurrency issue.

Suppose there is an account ABC which has $500 in it. User from web can transfer these funds to other accounts. This will involve 2 steps 1st checking availability of funds and 2nd transferring. I am making a transaction and doing both acts in it.

Problem is when in a time (say Time1) there are 2 or 3 seprate requests for transferring (say transaction1,transaction2, transaction3) same amount. Now committed available amount is $500. If all translations starts in same time, all will test is amount ($500) available ? which will true and next statement will transfer funds to other account.

I have read about Transaction isolation levels but I couldn’t decide which isolation level I should use, actually I am confuse in its understanding. Please help me.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:18:00+00:00Added an answer on May 24, 2026 at 12:18 am

    The aim is to prevent another process reading the balance but minimise blocking for other users. So use the “table as a queue” type locks thus:

    SET XACT_ABORT, NOCOUNT ON;
    BEGIN TRY
    
        BEGIN TRANSACTION
    
        SELECT @balance = Balance
        FROM SomeTable WITH (ROWLOCK, HOLDLOCK, UPDLOCK)
        WHERE Account = 'ABC'
    
        --some checks
    
        UPDATE ...
    
        COMMIT TRANSACTION
    END TRY
    BEGIN CATCH
      ...
    END CATCH
    

    The alternative is to do it in one, which is more feasible if there is one table involved.
    The CROSS JOIN is a test to

    SET XACT_ABORT, NOCOUNT ON;
    BEGIN TRY
    
        --BEGIN TRANSACTION
    
        UPDATE SomeTable WITH (ROWLOCK, HOLDLOCK, UPDLOCK)
        SET Balance = Balance - @request
        WHERE
           ST.Account = 'ABC' AND Balance > @request;
        IF @@ROWCOUNT <> 1
           RAISERROR ('Not enough in account', 16, 1);
    
        --COMMIT TRANSACTION
    END TRY
    BEGIN CATCH
      ...
    END CATCH
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing an Financial Winforms application and am having some trouble with the
We have an application that works with financial data that is schemaless. More accurately,
doing a simple login for my website, which will hopefully keep the user logged
Doing my first SL4 MVVM RIA based application and i ran into the following
When doing an INSERT with a lot of data, ie: INSERT INTO table (mediumtext_field)
doing this in AppDelegate: viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; Is there any problem
Doing a very simple loop to display various data, for _test in @test ...
Doing some archiving/deleting of some uncommonly used databases on an Oracle server. Has anyone
I work on a large financial system which is hosted on WebSphere and currently
So, I am debugging a pretty complex financial reporting application, where almost all of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.