Re: DbProviderFactory and transactions.
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 31 May 2007 16:29:31 -0400
Luigi,
See inline:
- I need to insert data in the first if not present
Using transactions if when I check I see I can proceed to insertion and
another concurrent access arrives before my insertion, I'll get an
exception as soon as I do executeNonQuery?
You won't have an exception. If you have a serializable transaction and
you are inserting the record into the database, the other transaction that
tries to perform an operation will block until you are done with the first
transaction.
If you are looking to update this data in the event that the record is
already inserted, then you should select the data out first (or do something
to obtain the lock) and then if you get any rows back, perform an update,
otherwise, perform an insert.
- I need to do noop if I'm trying to insert data in all the tables and one
field has the same value of that in the data I want to insert
How can I check this at the moment of insertion?
Maybe I've to create a good SQL query with a select in the where clause of
an insert?
Why bother? If you are performing an update, and the fields that you
are updating are the same as the fields that are already there, then its the
same thing as a no-op. There is no reason to check every field in the
table.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
.
- References:
- DbProviderFactory and transactions.
- From: BLUE
- Re: DbProviderFactory and transactions.
- From: Nicholas Paldino [.NET/C# MVP]
- Re: DbProviderFactory and transactions.
- From: BLUE
- Re: DbProviderFactory and transactions.
- From: Nicholas Paldino [.NET/C# MVP]
- Re: DbProviderFactory and transactions.
- From: BLUE
- Re: DbProviderFactory and transactions.
- From: Nicholas Paldino [.NET/C# MVP]
- Re: DbProviderFactory and transactions.
- From: BLUE
- DbProviderFactory and transactions.
- Prev by Date: SerializationException
- Next by Date: Re: Handling JavaScript functions and closures passed into C# function
- Previous by thread: Re: DbProviderFactory and transactions.
- Next by thread: Preferred way of ending a windows service.
- Index(es):
Relevant Pages
|