Re: [HACKERS] Whos idea was this

From: Craig Spannring <Craig(dot)Spannring(at)aedinc(dot)net>
To: "Andrij Korud" <akorud(at)polynet(dot)lviv(dot)ua>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Whos idea was this
Date: 1999-11-01 17:17:42
Message-ID: 199911011717.KAA17268@kampong.aedinc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 really STUPID.

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(dot)Spannring(at)aedinc(dot)net
--------------------------------+------------------------------------
Any sufficiently horrible technology is indistinguishable from Perl.
=======================================================================

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrij Korud 1999-11-01 17:20:01 Re: [HACKERS] Whos idea was this
Previous Message Andrij Korud 1999-11-01 17:10:56 Get OID of just inserted record