Re: Last Insert

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Marcelo Pereira <gandalf(at)sum(dot)desktop(dot)com(dot)br>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Last Insert
Date: 2002-03-13 16:58:03
Message-ID: 20020313085715.F82814-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

  • Last Insert at 2002-03-13 14:14:31 from Marcelo Pereira

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Rolland 2002-03-13 17:38:13 Re: vacuum causes pg_xlog directory to grow until out of disk space.
Previous Message Herb Blacker 2002-03-13 16:56:21 Bigint