Re: [HACKERS] getting new serial value of serial insert - Mailing list pgsql-hackers

From Ed Loehr
Subject Re: [HACKERS] getting new serial value of serial insert
Date
Msg-id 3821B622.FF93B1C1@austin.rr.com
Whole thread Raw
In response to RE: [HACKERS] getting new serial value of serial insert  ("Ansley, Michael" <Michael.Ansley@intec.co.za>)
List pgsql-hackers
I assume it is possible in pgsql to return the just-inserted serial value
with a stored procedure.

Stored procedures, though, would seem to be significantly more hassle vs.
the INSERT-returns-serial approach.  I share the concern about non-std
SQL, though it seems the pgsql system (like most other RDBMS) is
already loaded with non-std SQL precisely because the std has
repeatedly been judged lacking for itches that needed scratching.

As for concern about modifying INSERT semantics just for serial types,
that too, I would normally share.  A generalized solution is better.
However, the pg serial type is already a special case, constructed by
Postgres from other existing components unlike other types.  For that
reason, I think the case of facilitating an atomic return of the
serial value from a SQL insert statement would provide pragmatic
support for the key access mode to a special-case (non-std?) extension
already present.  For the same reason, it strikes me that the
generalized ability to return any value from an INSERT should be
treated as largely orthogonal to the special case serial type.

Cheers.
Ed

"Ansley, Michael" wrote:

> Why can't this simply be done with a stored proc?  Or am I missing the boat?
> Stored proc accepts parameters to insert, and returns whatever value you
> want it to.



pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] VIEWS, DISTINCT and COUNT
Next
From: Thomas Lockhart
Date:
Subject: Re: Performance glitch in GetCurrentAbsoluteTime()