Search Postgresql Archives

Using RETURNING with INTO inside pgsql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux