Re: [HACKERS] getting new serial value of serial insert

From: Ed Loehr <ELOEHR(at)austin(dot)rr(dot)com>
To: "Ansley, Michael" <Michael(dot)Ansley(at)intec(dot)co(dot)za>
Cc: "'Aaron J(dot) Seigo'" <aaron(at)gtv(dot)ca>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] getting new serial value of serial insert
Date: 1999-11-04 16:36:50
Message-ID: 3821B622.FF93B1C1@austin.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 1999-11-04 16:40:56 Re: Performance glitch in GetCurrentAbsoluteTime()
Previous Message Thomas Lockhart 1999-11-04 16:34:50 Re: [HACKERS] VIEWS, DISTINCT and COUNT