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

Reply via email to