oracle8.1.6
p.template_id = t.template_id and p.portal_id = portal.id_for_user(:package_id,:user_id)
select
p.portal_id,
p.name,
p.owner_id,
t.filename as template,
decode(acs_permission.permission_p(p.portal_id, :user_id, 'read'), 't', 1, 'f', 0) as portal_read_p,
decode(acs_permission.permission_p(t.template_id, :user_id, 'read'), 't', 1, 'f', 0) as layout_read_p
from portals p, portal_templates t
where $where