Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

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: Wed, 30 Sep 2009 03:11:52 -0700 (PDT)
  • Message-id: <25678362.post@talk.nabble.com> <text/plain>

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.




Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group