| From: | Darren Ferguson <darren(at)crystalballinc(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:53:51 | 
| Message-ID: | Pine.LNX.4.10.10203131153340.29890-100000@thread.crystalballinc.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
currval('id_of_the _sequence')
Darren Ferguson
Software Engineer
Openband
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);
> 
> As you can see, I don't know the ID number assigned to first.id, so I
> can't do the INSERT in the `second' table...
> 
> How can I discover the number gave to the SERIAL field in the first table?
> 
> Thanks in advance,
> 
> Marcelo
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Herb Blacker | 2002-03-13 16:56:21 | Bigint | 
| Previous Message | Jean-Michel POURE | 2002-03-13 16:42:26 | Re: missing greatbridge / database session monitor |