Discussion:
Conurrency in Insert sql
(too old to reply)
Giò
2005-09-12 15:17:31 UTC
Permalink
Hi,
I have a Table like this:
CREATE TABLE MYTABLE( ID_PK INTEGER NOT NULL, DATE_INI DATE, DATE_END DATE)
I need to polulate my table with data but each record cannot contain
overlapped date.
Example:
1, 10-10-2005, 10-12-2005
2, 10-13-2005, 10-15-2005. Correct

1, 10-10-2005, 10-12-2005
2, 10-11-2005, 10-15-2005. Incorrect.

With a single client this is simple, but if I have two clients in wich way
can I guarantee this rule without lock all table?

Thanks
Jeff Overcash (TeamB)
2005-09-12 15:28:31 UTC
Permalink
Post by Giò
Hi,
CREATE TABLE MYTABLE( ID_PK INTEGER NOT NULL, DATE_INI DATE, DATE_END DATE)
I need to polulate my table with data but each record cannot contain
overlapped date.
1, 10-10-2005, 10-12-2005
2, 10-13-2005, 10-15-2005. Correct
1, 10-10-2005, 10-12-2005
2, 10-11-2005, 10-15-2005. Incorrect.
With a single client this is simple, but if I have two clients in wich way
can I guarantee this rule without lock all table?
You will have to lock the table. Your only other option is to always verify
that the record you just committed (you have to do this after the commit)
doesn't violate your rules. You can not get a dirty read transaction level (I
don't know of any DB that implements this transaction level actually) which is
what you'd need to be able to see uncommitted work from other transactions.
Post by Giò
Thanks
--
Jeff Overcash (TeamB) On waves of silver I dreamed of gold
(Please do not email 'Till I lost the peace that dreaming gives
me directly unless I dreamed of the moment of my own death
asked. Thank You) That no one ever dreams and lives (Marillion)
Loading...