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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:35:51+00:00 2026-05-14T05:35:51+00:00

I have the following transaction: SQL inserts a 1 new record into a table

  • 0

I have the following transaction:

  1. SQL inserts a 1 new record into a table called tbl_document
  2. SQL deletes all records matching a criteria in another table called tbl_attachment
  3. SQL inserts multiple records into the tbl_attachment

Until this transaction finishes, I don’t want others users to be aware of the (1) new records in tbl_document, (2) deleted records in tbl_attachment, and (3) modified records in tbl_attachment.

Would Read Committed Isolation be the correct isolation level?

  • 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-14T05:35:52+00:00Added an answer on May 14, 2026 at 5:35 am

    yes, like this:

    BEGIN TRANSACTION
    
       insert into tbl_document ...
       delete tbl_attachment where ...
       inserts into tbl_attachment ...
    
    COMMIT
    

    you may block/lock users until you are finished and commit/rollback the transaction. Also, someone could SELECT your rows from tbl_attachment after your insert into tbl_document but before your delete. If you need to prevent that do this:

    BEGIN TRANSACTION
    
       select tbl_attachment with (UPDLOCK,HOLDLOCK) where ...
       insert into tbl_document ...
       delete tbl_attachment where ...
       inserts into tbl_attachment ...
    
    COMMIT
    

    or just delete tbl_attachment before the insert into tbl_document and forget the select with the locking hints.

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

Sidebar

Related Questions

If I have the following SQL query CREATE TABLE #t1 (a INT NOT NULL
I have an SQL Server database table created by deploying the following description in
I have the following T-SQL code: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE BEGIN TRANSACTION T1_Test
Suppose that I execute the following SQL statements: start transaction; insert into someTable (userId,
I have the following code which is in a transaction. I'm not sure where/when
I have a scenario where I need to do the following in a transaction:
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record
I am using following code: Note that i HAVE TO SEND SQL Query so
I have a program which executes sql statements. Within a transaction, I'd like to
I have a question about MySQL InnoDB. For example: I have the following table

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.