Deletion in Transaction(OffTopic)

Posted on 2004-11-25
Last Modified: 2010-04-15
We have a transaction where are making a series of delete and Insert.
Here I am checking whether the record is deleted or not.
If the record is deleted I want to insert the data.
Since this is a in a transaction the physical delete is not happening.
Here my running a select query to read the data from the database (Oracle)
My logic always goes to update since physical delete is not made.

Question by:rajaamirapu
    LVL 16

    Accepted Solution

    If you are in a transaction, then if you try the delete, then do the insert. If the delete fails, it will presumably error and roll back the transaction, and therefore so will the insert. If you don't try the delete, then do the update. Or am I misunderstanding what you are asking?
    LVL 9

    Assisted Solution

    A simple solution, if the transaction is via the Transaction property in Connection object and Command object, then set a boolean flag indicating the delete happened.
    LVL 10

    Assisted Solution

    If u are doing a Delete operation then u will be using the ExecuteNonQuery method of the command object.
    This method returns the number of rows affected buy the query. U can check that.

    Or if there is a any problem with the delete then an exception will occur. U can rollback the transaction. If the particular delete does not cause an exception and if no rows are affected then it means that the particular where row(filtered by where clause) did not exist in the database.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    Title # Comments Views Activity
    Problem with C# 1 44
    Removing Leading Zero in the MVC project 7 27 mvc C# 2 27
    Change to event 1 47
    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now