From: | <mkl(at)webde-ag(dot)de> |
---|---|
To: | "mixo" <mixo(at)coza(dot)net(dot)za> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Last insert id |
Date: | 2004-06-09 06:54:17 |
Message-ID: | 464355780@web.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I'm new on postgreSQL, so this might not be the simplest sollution:
Use a sequence instead of serial.
After you have generated the new id with your_seq.nextval
you can get thesame number again with your_seq.currval.
details at http://www.postgresql.org/docs/7.3/static/functions-sequence.html
mixo schrieb:
>I have three tables which are related a serial field, table1_id, in on
>of the tables. Updating the tables is done through a transaction. My
>problem is, once I have insert a row in the first tables with
>table1_id, I need for the other two tables. How can I get this? Is it
>safe to use "select max(table1_id) from table1" after the insert?
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2004-06-09 07:22:37 | Re: Last insert id |
Previous Message | Peter Eisentraut | 2004-06-09 06:36:25 | Re: Getting FK relationships from information_schema |