Getting last insert value

From: Yasir Malik <ymalik(at)cs(dot)stevens-tech(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Getting last insert value
Date: 2003-11-15 15:18:08
Message-ID: Pine.SGI.4.58.0311151003320.76056@guinness.cs.stevens-tech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,
I have a table with many fields, and one of the fields is of type serial.
I will do many inserts, and there will be many repeats of the other fields
in the table, but, obviously, the serial field will be unique for all the
rows. How can I get the value of serial field of the last row I inserted.
I know I can select the maximum value from the serial field, but is there
a better way, preferably something that takes constant time.
Thanks,
Yasir Malik

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message ow 2003-11-15 16:00:36 Re: Programatically switching database
Previous Message Peter Eisentraut 2003-11-15 10:11:47 Re: Programatically switching database