Thread: Whos idea was this

Whos idea was this

From
"Andrij Korud"
Date:
Hey, I just found that if I "BEGIN", making a lot of inserts (1000) and on
1001 insert I get an error (for example "duplicate key") ALL prev 1000
insertes I LOST.
Give me please author of this %$%$^&%# idea!!! It's really STUPID.

Andriy Korud, Lviv, Ukraine
P.S. Sorry for this letter but I'm really angy. Can postgres give me the way
to store uniq data in datable without checking before each insert if this
data alredy exist or no. Why it cannot give me error about duplicate keys
which I will (or will not) take in care.



Re: [HACKERS] Whos idea was this

From
Craig Spannring
Date:
Andrij Korud writes:> Hey, I just found that if I "BEGIN", making a lot of inserts (1000) and on> 1001 insert I get an
error(for example "duplicate key") ALL prev 1000> insertes I LOST.> Give me please author of this %$%$^&%# idea!!! It's
reallySTUPID.
 


Actually, that's the way it's supposed to work.  Most modern
relational databases support what are called transactions.  A
transaction is an indivisible unit of work for the database engine.

By starting a transaction (using the 'BEGIN') you are telling the
database engine that you want it to make the updates if and only if
_all_ of the updates can succeed.  If any updates that will fail the
database engine will make sure that none of the updates take place.

Transactions come in really handy if we have updates on a set of mutually
dependent tables.  Frequently we don't want to update any of the
tables unless we can sucdeed in updating all of the tables.

If you have a set of updates that aren't mutually dependent, just use
a 'COMMIT TRANSACTION' between each update.


-- 
=======================================================================Life is short.                  | Craig
Spannring     Bike hard, ski fast.       |
Craig.Spannring@aedinc.net--------------------------------+------------------------------------Anysufficiently horrible
technologyis indistinguishable from Perl.
 
=======================================================================



Re: [HACKERS] Whos idea was this

From
"Andrij Korud"
Date:
Sorry for first angry letter and let close this theme.
Sorry once more.

Andriy Korud, Lviv, Ukraine