select portal_id
from portals
where package_id = :package_id
and owner_id <> :package_id
select count(*)
from portal_datasources pd
where pd.application = :one_application
and exists (select 1
from portal_datasource_map pdm
where pdm.package_id = :package_id
and pdm.datasource_id = pd.datasource_id)
insert into portal_datasource_map
(datasource_id, package_id)
select pd.datasource_id, :package_id
from portal_datasources pd
where pd.application = :one_application
select name
from portal_datasources
where application = :one_application
and admin_p = 'f'
select name
from portal_datasources
where application = :one_application
and admin_p = 't'