Last value inserted - Mailing list pgsql-general

From MaRCeLO PeReiRA
Subject Last value inserted
Date
Msg-id 20041111125916.82486.qmail@web52703.mail.yahoo.com
Whole thread Raw
Responses Re: Last value inserted
Re: Last value inserted
Re: Last value inserted
Re: Last value inserted
Re: Last value inserted
List pgsql-general
Hi guys,

I am in troubles with a SERIAL field.

I have five tables. A parent table and four child
tables. When I do the INSERT in the parent table, I
have an ID (generated) by the sequence (SERIAL field),
and I have to use this ID to reference all child
tables.

Well, once I do an INSERT in the parent table, how can
I know (for sure) which number id was generated by the
sequence?

Simple example:

------------------------------------------------------
CREATE TABLE parent(id SERIAL, descrip CHAR(50));
------------------------------------------------------

So,

------------------------------------------------------
INSERT INTO parent (descrip) VALUES ('project 1');
------------------------------------------------------

How can I now (for sure) with value was generated by
the sequence to fill the field ID?

(There is lots of users using the software at the same
time, so I am not able to use the last_value()
function on the sequence.)

Best Regards,

Marcelo Pereira
Brazil





_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/

pgsql-general by date:

Previous
From: Shridhar Daithankar
Date:
Subject: New Opteron server from pogo linux
Next
From: Tom Lane
Date:
Subject: Re: Can't insert date in field with foreign key