Example => Best way to check the app_user active roles:
SELECT COUNT(*)
INTO __counter
FROM (SELECT rolekey FROM public.app_user_active_roles_get_internal( __app_user_rid, __compkey, null, null )) AS tmp
WHERE rolekey IN ('SUPERUSER', 'EMP_ADMIN', 'DB_REPLICATOR');
Example => Best way to check combination and validity of compkey/appUserRid:
SELECT COUNT(*)
INTO __counter
FROM (SELECT rolekey FROM public.app_user_active_roles_get_internal( __app_user_rid, __compkey, null, null )) AS tmp;
IF __counter < 1 THEN
/*The combination compkey/appUserRid is not valid*/
__error_description = (SELECT _propdesc FROM public.sys_error_get( __lngkey, '0005'));
RETURN json_build_object(
'success', false,
'errors', json_agg(
json_build_object(
'code', '0005',
'message', __error_description,
'moreInfo', null
)
)
);
END IF;