• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Deletion in Transaction(OffTopic)

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.

0
rajaamirapu
Asked:
rajaamirapu
3 Solutions
 
muzzy2003Commented:
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?
0
 
JoeisanerdCommented:
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.
0
 
123654789987Commented:
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.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now