postgresql7.1 select site_node__url(:node_id) select package_id, acs_object__name(package_id) as name from apm_packages where (acs_permission__permission_p(package_id, :user_id, 'read') = 't' or acs_permission__permission_p(package_id, acs__magic_object_id('the_public'), 'read') = 't') and apm_package__singleton_p(package_key) = 0 and not exists (select 1 from site_nodes where object_id = package_id) order by name select package_id, acs_object__name(package_id) as name from apm_packages where (acs_permission__permission_p(package_id, :user_id, 'read') = 't' or acs_permission__permission_p(package_id, acs__magic_object_id('the_public'), 'read') = 't') and exists (select 1 from site_nodes where object_id = package_id) order by name select package_id, acs_object__name(package_id) as name from apm_packages where (acs_permission__permission_p(package_id, :user_id, 'read') = 't' or acs_permission__permission_p(package_id, acs__magic_object_id('the_public'), 'read') = 't') and apm_package__singleton_p(package_key) = 1 and not exists (select 1 from site_nodes where object_id = package_id) order by name