postgresql7.1
select case when exists (
select 1
from application_group_element_map
where package_id = :package_id
and element_id = :party_id
union all
select 1
from application_groups
where package_id = :package_id
and group_id = :party_id
) then 1 else 0 end
select case when exists (
select 1
from application_group_element_map
where package_id = :package_id
and element_id = :party_id
union all
select 1
from application_groups
where package_id = :package_id
and group_id = :party_id
) then 1 else 0 end
select case when exists (
select 1
from application_group_element_map
where package_id = :package_id
and rel_id = :rel_id
) then 1 else 0 end
select case when exists (
select 1
from application_group_segments
where package_id = :package_id
and segment_id = :segment_id
) then 1 else 0 end
select application_group__group_id_from_package_id (
:package_id,
:no_complain_p
)
select ag.group_id as parent_group_id
from (select tree_ancestor_keys(site_node_get_tree_sortkey(:parent_node_id)) as tree_sortkey) parents,
application_groups ag, site_nodes s, apm_packages a
where s.tree_sortkey = parents.tree_sortkey
and s.object_id = a.package_id
and a.package_id = ag.package_id
order by s.tree_sortkey desc
limit 1;
select application_group__new (
:group_id,
:group_type,
now(),
:creation_user,
:creation_ip,
:email,
:url,
:group_name,
:package_id,
:parent_group_id
)