Thread: sequences in transaction blocks

sequences in transaction blocks

From
"Marian Naghen"
Date:
I want to insert records inside a transaction block (BEGIN - COMMIT/ROLLBACK). If the transaction fails,
the sequence do not rollback and retain the new value.
 
This is the default behavior of sequences ?
 
 
I use the following table:
 
CREATE TABLE proceduri
(
  procedura_id int4 NOT NULL DEFAULT nextval('proceduri_proceduri_id_seq'::regclass),
  tip_procedura_id int4,
  ....
  CONSTRAINT proceduri_pkey PRIMARY KEY (procedura_id)
)
WITH OIDS;
 
where 'proceduri_proceduri_id_seq is:
 
CREATE SEQUENCE proceduri_proceduri_id_seq
  INCREMENT 1
  MINVALUE 1000000000
  MAXVALUE 1099999999
  START 1000000001
  CACHE 1;
 
 
 

Re: sequences in transaction blocks

From
"A. Kretschmer"
Date:
am  19.12.2005, um  9:39:11 -0000 mailte Marian Naghen folgendes:
> I want to insert records inside a transaction block (BEGIN - COMMIT/ROLLBACK). If the transaction fails,
> the sequence do not rollback and retain the new value.
>
> This is the default behavior of sequences ?

Yes.


HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

Re: sequences in transaction blocks

From
Tino Wildenhain
Date:
Am Montag, den 19.12.2005, 09:39 +0000 schrieb Marian Naghen:
> I want to insert records inside a transaction block (BEGIN -
> COMMIT/ROLLBACK). If the transaction fails,
> the sequence do not rollback and retain the new value.
>
> This is the default behavior of sequences ?

Yes it is (its the whole point of sequences)
please see the docs, for example:

http://www.postgresql.org/docs/current/static/functions-sequence.html

especially the last paragraph.

HTH
Tino Wildenhain


Re: sequences in transaction blocks

From
"Marian Naghen"
Date:
Okay, all clear.

Thanx a lot.


----- Original Message -----
From: "Tino Wildenhain" <tino@wildenhain.de>
To: "Marian Naghen" <naghen@ratb.ro>
Cc: <pgsql-general@postgresql.org>
Sent: Monday, December 19, 2005 7:50 AM
Subject: Re: [GENERAL] sequences in transaction blocks


> Am Montag, den 19.12.2005, 09:39 +0000 schrieb Marian Naghen:
> > I want to insert records inside a transaction block (BEGIN -
> > COMMIT/ROLLBACK). If the transaction fails,
> > the sequence do not rollback and retain the new value.
> >
> > This is the default behavior of sequences ?
>
> Yes it is (its the whole point of sequences)
> please see the docs, for example:
>
> http://www.postgresql.org/docs/current/static/functions-sequence.html
>
> especially the last paragraph.
>
> HTH
> Tino Wildenhain
>