A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Use variables with Postgres, just like MySQL

It's a little more difficult than MySQL, as you have to create a function to contain the logic:

DROP FUNCTION get_column(integer);
CREATE FUNCTION get_column(row_id integer) RETURNS text AS $$
DECLARE
    t1_row foo%ROWTYPE;
BEGIN
    SELECT * INTO t1_row FROM foo WHERE foo.status != 'closed' limit 1;
    RETURN t1_row;
END;
$$ LANGUAGE plpgsql;

SELECT get_column(3);