select
coalesce(true = ANY(array_agg(to_email)), false),
coalesce(true = ANY(array_agg(to_ui)), false)
into to_email_v, to_ui_v
from mail.members_group_recipients
where id_group = group_addr;
select
coalesce(to_portal, false),
case
when coalesce(to_portal, false) = true
and chat_idx is not null
then ARRAY[chat_idx]::text[]
else ARRAY[]::text[]
end
into to_portal_v, attr_chat_portal
from mail.list_group_recipients
where id = group_addr;