Re: SQL-question: returning the id of an insert querry

Поиск
Список
Период
Сортировка
От Scott Chapman
Тема Re: SQL-question: returning the id of an insert querry
Дата
Msg-id 200311121146.44509.scott_list@mischko.com
обсуждение исходный текст
Ответ на Re: SQL-question: returning the id of an insert querry  (Doug McNaught <doug@mcnaught.org>)
Ответы Re: SQL-question: returning the id of an insert querry
Список 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 по дате отправления:

Предыдущее
От: Paul Thomas
Дата:
Сообщение: Re: RHEL
Следующее
От: "Brett Maton"
Дата:
Сообщение: Column Sizes