Re: SQL-question: returning the id of an insert querry - Mailing list pgsql-general

From Scott Chapman
Subject Re: SQL-question: returning the id of an insert querry
Date
Msg-id 200311121146.44509.scott_list@mischko.com
Whole thread Raw
In response to Re: SQL-question: returning the id of an insert querry  (Doug McNaught <doug@mcnaught.org>)
Responses Re: SQL-question: returning the id of an insert querry
List pgsql-general
On Wednesday 12 November 2003 11:29, Doug McNaught wrote:
> Scott Chapman <scott_list@mischko.com> writes:
> > It would be nice if PostgreSQL could return the primary key it
> > inserted with but that may not be a fool-proof solution either.  Is
> > there a nice way to handle this situation?
>
> Write a database function that inserts the record and returns the
> primary key value?  That's probably the best way to insulate your app
> from the database structure...

The function still has to know which sequence to pull from doesn't it?

I don't know much about triggers/functions in PG.  Is it possible to
have a function that intercepts the information AFTER the sequence
value is added as the new primary key and then return it?  This would
enable the use of a more generic function.

Scott


pgsql-general by date:

Previous
From: Paul Thomas
Date:
Subject: Re: RHEL
Next
From: "Brett Maton"
Date:
Subject: Column Sizes