Re: [GENERAL] get the previous assigned sequence value - Mailing list pgsql-general

From Silvio Macedo
Subject Re: [GENERAL] get the previous assigned sequence value
Date
Msg-id Pine.LNX.4.21.9912101658560.30628-100000@test133.ee.ic.ac.uk
Whole thread Raw
List pgsql-general
>Date: Thu, 9 Dec 1999 16:35:35 +0200
>From: "Nikolay Mijaylov" <nmmm@nmmm.nu>
>Re: [GENERAL] get the previous assigned sequence value
>Why you discuss it????
>The problem is quite clean and it was solvev many years ago.....
>1. Get the *next* sequence value:
>select nextval("gogo_seq");
>2. Store it into a variable (for example $X)
>3. Insert proper data (and and sequence value)
>insert into gogo values( $X, 'NMMM', 'mailto:nmmm@nmmm.nu');
>4. Use value $X, as u want
>insert into gogo_detail values( $X, 'bla bla0');
>insert into gogo_detail values( $X, 'bla bla1');
>insert into gogo_detail values( $X, 'bla bla2');
>Am I clear?
>nmmm

No comments...
Just imagine that the transaction aborts after you did select
nexval().

--
``````````````` Silvio Emanuel Nunes Barbosa de Macedo '''''''''''''''''''
smacedo@ic.ac.uk                                         smacedo@inescn.pt
Imperial College, University of London                         INESC Porto
Intelligent and Interactive Systems                Telecom. and Multimedia
Exhibition Road,                                       Pc da Republica, 93
London SW7 2AZ, England                            4050-497 PORTO PORTUGAL
Tel:+44 171 5946323                                    Tel:+351 22 2094220


pgsql-general by date:

Previous
From: Karl DeBisschop
Date:
Subject: \d shows all my tables twice
Next
From: Bruce Momjian
Date:
Subject: Re: [GENERAL] \d shows all my tables twice