Using RETURNING with INTO inside pgsql - Mailing list pgsql-general

From D. Dante Lorenso
Subject Using RETURNING with INTO inside pgsql
Date
Msg-id 46F352B6.9040203@lorenso.com
Whole thread Raw
Responses Re: Using RETURNING with INTO inside pgsql  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Re: Using RETURNING with INTO inside pgsql  (Ben <bench@silentmedia.com>)
List pgsql-general
Not really a question here, I just wanted to share my joy with the
group.  I'm loving the new RETURNING clause in PostgreSQL.  This is
really cool stuff ...

-------------------- 8< --------------------
CREATE OR REPLACE FUNCTION "public"."testfunc" () RETURNS bigint AS
$body$
DECLARE
     my_var BIGINT;
BEGIN
     INSERT INTO tryit (col1, col2)
     VALUES ('a', 'b')
     RETURNING prikey
     INTO my_var;

     RETURN my_var;
END;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
-------------------- 8< --------------------

I never do anything this trivial inside a stored proc, but the point is
not what I'm doing but rather how it's done.  That RETURNING clause
really helps reduce the amount of SQL I have to write.  PostgreSQL 8.2.4
rocks!

-- Dante

pgsql-general by date:

Previous
From: Jerry Sievers
Date:
Subject: Re: Adding domain type with CHECK constraints slow on large table
Next
From: "Scott Marlowe"
Date:
Subject: Re: Using RETURNING with INTO inside pgsql