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

From rintaant
Subject Re: INSERT with RETURNING clause inside SQL function
Date
Msg-id 25678362.post@talk.nabble.com
Whole thread Raw
In response to INSERT with RETURNING clause inside SQL function  ("Diego Schulz" <dschulz@gmail.com>)
List 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.


pgsql-general by date:

Previous
From: Sydney Puente
Date:
Subject: ms-sql -> pg 8.x
Next
From: Tom Lane
Date:
Subject: Re: Updating row with updating function, bug or feature?