Re: Last insert id

Поиск
Список
Период
Сортировка
От Andrei Bintintan
Тема Re: Last insert id
Дата
Msg-id 20040615070408.80EA4175A8@ar-sd.net
обсуждение исходный текст
Ответ на Last insert id  (mixo <mixo@coza.net.za>)
Ответы Re: Last insert id
Re: Last insert id
Список pgsql-sql
"Is it safe to use "select max(table1_id) from table1" after the insert?"

Yes it is safe, but ONLY if you use it inside a transaction.(BEGIN/COMMIT).

BR.


-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]
On Behalf Of mixo
Sent: Wednesday, June 09, 2004 9:24 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] Last insert id

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




В списке pgsql-sql по дате отправления:

Предыдущее
От: "Jie Liang"
Дата:
Сообщение: Prepare Statement
Следующее
От: Rod Taylor
Дата:
Сообщение: Re: Last insert id