postgresql7.1
select case_id,
acs_object__name(object_id) as object_name,
state,
workflow_key
from wf_cases
where case_id = :case_id
select p.party_id,
acs_object__name(p.party_id) as name,
case when p.email = '' then '' else '('||p.email||')' end as email
from parties p
where 0 < (select count(*)
from users u, party_approved_member_map m
where m.party_id = p.party_id
and u.user_id = m.member_id)