CREATE OR REPLACE FUNCTION office.get_office_id_by_store_id(integer) RETURNS integer LANGUAGE plpgsql AS $function$ BEGIN RETURN office_id FROM office.stores WHERE store_id=$1; END $function$