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 6811187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:17:47+00:00 2026-05-26T20:17:47+00:00

if I use transactions, will it lock the tables and prevent it from making

  • 0

if I use transactions, will it lock the tables and prevent it from making any changes by other users?

pseudo code:

 begin transaction
   issue a select query
   issue a update query
 end transaction

so, in between those two queries, is it possible to make some changes by another update statement or something which was issued from another page ?

or since the beginning of the transaction, will the tables used be locked ?

What is the difference between transaction and lock table? will a transaction implicitly lock the table ?

Edit:
This is what i want to do:

{
    // Check Table2 (posted messages)
    // If is_approved is FALSE for a given msg_id
    {
        // Set is_approved to TRUE
        // Update Table1 (member details) post_count_month++
        //     and post_count_lifetime++
    }
    // Else
    {
        // NOOP
    }
}

Above updation can be made by several users at the same time. Also, a single user(Admin) could delete a message(both accepted and not accepted message). So for deleting, the countmonth and countlifetime of the user who had posted that message(the one to be deleted) should be incremented and then message is deleted.

This is the two situation I am facing.

  • 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-26T20:17:48+00:00Added an answer on May 26, 2026 at 8:17 pm

    Transactions and table locking are different features that solve different problems. In your case you only seem to perform one write operation into the database, thus using a transaction will not provide any benefit unless you want to able to undo the update.

    Have a look at the SELECT … FOR UPDATE statement.

    Update #1:

    Alright, here you are some code:

    START TRANSACTION;
    
    SELECT member_id, is_approved
    FROM posted_messages
    WHERE msg_id=31416
    FOR UPDATE;
    
    UPDATE member_details
    SET post_count_month=post_count_month+1, post_count_lifetime=post_count_lifetime+1
    WHERE member_id=123;
    
    UPDATE posted_messages
    SET is_approved=TRUE
    WHERE msg_id=31416;
    
    COMMIT;
    

    (I’m not sure about how helpful it’ll be, considering that I’ve invented all the queries. Understanding the code is always better than copying and pasting.)

    Update #2:

    I’ve edited the sample code to surround the queries in a transaction. I said that transactions and table locking are different features and it’s still true. However, the SELECT ... FOR UPDATE works inside a transaction. It’s just an implementation detail.

    Locking of rows for update using SELECT FOR UPDATE only applies when
    autocommit is disabled (either by beginning transaction with START
    TRANSACTION or by setting autocommit to 0. If autocommit is enabled,
    the rows matching the specification are not locked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to use transactions in Entity Framework? I read some links on Stackoverflow :
Is it possible to use the SQL BEGIN TRANSACTION, COMMIT TRANSACTION, ROLLBACK TRANSACTION when
I am thinking of writing a tool that will list all the tables in
I was recently told that I should use transactions in my application as they
From this post . One obvious problem is scalability/performance. What are the other problems
I have an application I am working on that will need the use of
I have a table of transactions which will occasionally have duplicate entries. If/When an
I need to create an application that will use Flex on the client side
I have a simple app that use org.springframework.jdbc.datasource.DataSourceTransactionManager to manage the transactions. My spring
I am developing an application that will be used by many users in the

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.