Re: Last Insert - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Last Insert
Date
Msg-id 20020313085715.F82814-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Last Insert  (Marcelo Pereira <gandalf@sum.desktop.com.br>)
Responses Re: Last Insert
List pgsql-general
On Wed, 13 Mar 2002, Marcelo Pereira wrote:

> Hello All,
>
> I have two tables, the first is parental and the second is a child of the
> first.
>
> Ex.:
>
> create table first (id SERIAL, descrip CHAR(20));
> create table second (id INTEGER references first(id), state CHAR(2));
>
> I have `all' the values to make the inserts in the two tables (ie, descrip
> and state), so I `would' use:
>
> INSERT into first (descrip) values ($descr);
> INSERT into second (id,state) values (?????????,$state);

currval('first_id_seq') should get you the last sequence value given to
your session.


pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Referential integrity violation
Next
From: Jean-Michel POURE
Date:
Subject: Re: Stored procedure in PostgreSQL