Last value inserted
| От | MaRCeLO PeReiRA |
|---|---|
| Тема | Last value inserted |
| Дата | |
| Msg-id | 20041111125916.82486.qmail@web52703.mail.yahoo.com обсуждение исходный текст |
| Ответы |
Re: Last value inserted
Re: Last value inserted Re: Last value inserted Re: Last value inserted Re: Last value inserted |
| Список | 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 по дате отправления: