pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yasir Malik <ymalik@cs.stevens-tech.edu>
To: pgsql-sql@postgresql.org
Subject: Getting last insert value
Date: Sat, 15 Nov 2003 10:18:08 -0500
Message-ID: <Pine.SGI.4.58.0311151003320.76056@guinness.cs.stevens-tech.edu> (raw)

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



view thread (7+ messages)  latest in thread

Message-ID: <Pine.SGI.4.58.0311151003320.76056@guinness.cs.stevens-tech.edu>
Permalink:  ../Pine.SGI.4.58.0311151003320.76056@guinness.cs.stevens-tech.edu/
Also on:    postgresql.org/message-id/Pine.SGI.4.58.0311151003320.76056@guinness.cs.stevens-tech.edu

 · 

reply

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: ymalik@cs.stevens-tech.edu
  Subject: Re: Getting last insert value
  In-Reply-To: <Pine.SGI.4.58.0311151003320.76056@guinness.cs.stevens-tech.edu>

* 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