Re: INSERT with RETURNING clause inside SQL function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Diego Schulz" <dschulz(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: INSERT with RETURNING clause inside SQL function
Date: 2008-11-03 23:51:02
Message-ID: 2039.1225756262@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Diego Schulz" <dschulz(at)gmail(dot)com> writes:
> I expected something like this to work, but it doesn't:

> CREATE OR REPLACE FUNCTION add_something(text, text) RETURNS INTEGER AS $$
> INSERT INTO sometable (id, foo, bar ) VALUES (DEFAULT, $1, $2 )
> RETURNING id ;
> $$ LANGUAGE SQL ;

This case was implemented last week. In existing release branches
you'll need to use currval or some other workaround to collect the
serial value.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Neufeld 2008-11-04 00:29:22 many tables vs large tables
Previous Message Chris 2008-11-03 23:05:45 Re: Debugging infrequent pegged out CPU usage