DECLARE foo INT DEFAULT 0; SELECT max(fooID) INTO foo from a_table; SELECT foo;