Re: [GENERAL] get the previous assigned sequence value

From: Silvio Macedo <smacedo(at)ic(dot)ac(dot)uk>
To: nmmm(at)nmmm(dot)nu, pgsql general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] get the previous assigned sequence value
Date: 1999-12-10 17:08:51
Message-ID: Pine.LNX.4.21.9912101658560.30628-100000@test133.ee.ic.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>Date: Thu, 9 Dec 1999 16:35:35 +0200
>From: "Nikolay Mijaylov" <nmmm(at)nmmm(dot)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(at)nmmm(dot)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(at)ic(dot)ac(dot)uk smacedo(at)inescn(dot)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

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 1999-12-10 17:15:13 Re: [GENERAL] \d shows all my tables twice
Previous Message Karl DeBisschop 1999-12-10 17:02:46 \d shows all my tables twice