Re: INSERT with RETURNING clause inside SQL function - Mailing list pgsql-general

From Diego Schulz
Subject Re: INSERT with RETURNING clause inside SQL function
Date
Msg-id 47dcfe400811031926s1a3f2b50la22e2b7e9931b65e@mail.gmail.com
Whole thread Raw
In response to Re: INSERT with RETURNING clause inside SQL function  (Raymond O'Donnell <rod@iol.ie>)
Responses Re: INSERT with RETURNING clause inside SQL function
List pgsql-general
On Mon, Nov 3, 2008 at 10:24 PM, Raymond O'Donnell <rod@iol.ie> wrote:
> On 04/11/2008 01:20, Diego Schulz wrote:
>
>> I also tried this (somewhat silly) syntax to circumvent the issue
>> without resorting in currval:
>
> Just curious - what have you got against currval()? It seems to me that
> it would make your life easier....
>
> Ray.
>
>
> ------------------------------------------------------------------
> Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
> rod@iol.ie
> Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
> ------------------------------------------------------------------
>

I simply don't like having to cast from BIGINT to INTEGER,
as currval returns BIGINT while the index of my table is INTEGER.
I think isn't as readable and elegant as the single INSERT ... RETURNING value.

Being the only choice at this time (that I'm aware of) I'm using
something like this:

SELECT CAST(CURRVAL('mytable_id_seq') AS INTEGER);

If I can avoid messing with sequence manipulation functions, surely I will.

Cheers!

pgsql-general by date:

Previous
From: Jonathan Guthrie
Date:
Subject: I'm puzzled by a foreign key constraint problem
Next
From: Craig Ringer
Date:
Subject: Re: I'm puzzled by a foreign key constraint problem