pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: Get the last inserted id
Date: Fri, 11 Apr 2008 19:48:06 +0200
Message-ID: <20080411174806.GA21064@a-kretschmer.de> (raw)
In-Reply-To: <f16f7ea00804111023xc2072ddk796b1e0336c14aac@mail.gmail.com>
References: <f16f7ea00804111023xc2072ddk796b1e0336c14aac@mail.gmail.com>

am  Fri, dem 11.04.2008, um 19:23:04 +0200 mailte Nacef LABIDI folgendes:
> Hi all,
>  
> I was wondering if postgres can return the last ID inserted for a table which
> the primary key is autoincremented. I need to retrieve this ID in my code to
> continue processing on that inserted row.

Either with RETURNING:
http://www.postgresql.org/docs/current/static/sql-insert.html

or with currval():
http://www.postgresql.org/docs/current/static/functions-sequence.html


HTH, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net



view thread (5+ messages)  latest in thread

Message-ID: <20080411174806.GA21064@a-kretschmer.de>
Permalink:  ../20080411174806.GA21064@a-kretschmer.de/
Also on:    postgresql.org/message-id/20080411174806.GA21064@a-kretschmer.de

 · 

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: andreas.kretschmer@schollglas.com
  Subject: Re: Get the last inserted id
  In-Reply-To: <20080411174806.GA21064@a-kretschmer.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