From: | "D(dot) Dante Lorenso" <dante(at)lorenso(dot)com> |
---|---|
To: | Postgres-General <pgsql-general(at)postgresql(dot)org> |
Subject: | Using RETURNING with INTO inside pgsql |
Date: | 2007-09-21 05:12:22 |
Message-ID: | 46F352B6.9040203@lorenso.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2007-09-21 05:23:59 | Re: Using RETURNING with INTO inside pgsql |
Previous Message | Charles.Hou | 2007-09-21 02:10:59 | Re: about pgpool question |