postgresql7.1
select
case when m.element_id = e.element_id then 1 else 0 end as local_p,
case when acs_permission__permission_p(:element_id, :user_id, 'delete') = 't' then 1 else 0 end as element_delete_p
from portal_available_element_map m, portal_elements e
where
m.element_id = e.element_id and
m.element_id = :element_id and
m.portal_id = :default_portal_id
select portal_element__delete(:element_id);