CREATE OR REPLACE FUNCTION office.get_sys_user_id()
RETURNS integer
LANGUAGE plpgsql
AS $function$
BEGIN
RETURN
(
SELECT office.users.user_id
FROM office.roles, office.users
WHERE office.roles.role_id = office.users.role_id
AND office.roles.is_system=true LIMIT 1
);
END
$function$