>> John McCawley <nospam@xxxxxxxxxxxx> writes: >>> CREATE FUNCTION new_get_emp_id() RETURNS INTEGER AS $$ select emp_id >>> from secureview.tbl_employee where username = (SELECT current_user) $$ >>> LANGUAGE SQL IMMUTABLE; One other thing: that no-op sub-SELECT isn't doing anything for you except adding overhead ... you might've needed it to allow index use back in 7.2 or before, but not in any remotely modern PG release. regards, tom lane