postgresql7.1
select
e.config_id,
d.default_config_id,
case when acs_permission__permission_p(e.config_id, :user_id, 'write') = 't' then 1 else 0 end as write_p,
case when d.configurable_p = 't' then 1 else 0 as configurable_p
from portal_datasources d, portal_elements e
where e.datasource_id = d.datasource_id and e.element_id = :element_id