Re: INSERT with RETURNING clause inside SQL function

From: rintaant <antero(dot)rintamaki(at)netikka(dot)fi>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: INSERT with RETURNING clause inside SQL function
Date: 2009-09-30 10:11:52
Message-ID: 25678362.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


you can try:
CREATE OR REPLACE FUNCTION add_something(text, text)
RETURNS integer AS
$BODY$
DECLARE
somevariable integer;
BEGIN
INSERT INTO sometable (id, foo, bar ) VALUES (DEFAULT, $1, $2 ) RETURNING id
INTO somevariable;
return somevariable;
END;$BODY$ LANGUAGE 'plpgsql' VOLATILE;

--
View this message in context: http://www.nabble.com/INSERT-with-RETURNING-clause-inside-SQL-function-tp20312197p25678362.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bronagh Grimes 2009-09-30 10:13:06 PostgreSQL Macro Query
Previous Message Peter Eisentraut 2009-09-30 09:24:16 Re: Collation in ORDER BY not lexicographical