From: mkl@webde-ag.de
To: mixo <mixo@coza.net.za>
Cc: pgsql-sql@postgresql.org
Subject: Re: Last insert id
Date: Wed, 09 Jun 2004 08:54:17 +0200
Message-ID: <464355780@web.de> (raw)
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
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mkl@webde-ag.de, mixo@coza.net.za
Subject: Re: Last insert id
In-Reply-To: <464355780@web.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox