postgresql7.1
select '[db_quote $sender_email]' as from_addr,
'[db_quote $sender_first_names]' as sender_first_names,
'[db_quote $sender_last_name]' as sender_last_name,
parties.email,
(case acs_objects.object_type
when 'user' then
(select first_names
from persons
where person_id = parties.party_id)
when 'group' then
(select group_name
from groups
where group_id = parties.party_id)
when 'rel_segment' then
(select segment_name
from rel_segments
where segment_id = parties.party_id)
else '' end) as first_names,
(case acs_objects.object_type
when 'user' then
(select last_name
from persons
where person_id = parties.party_id)
else '' end) as last_name,
'[db_quote $community_name]' as community_name,
'[db_quote $community_url]' as community_url
from party_approved_member_map,
parties,
acs_objects
where party_approved_member_map.party_id = $segment_id
and party_approved_member_map.member_id <> $segment_id
and party_approved_member_map.member_id = parties.party_id
and parties.party_id = acs_objects.object_id
select '[db_quote $sender_email]' as from_addr,
'[db_quote $sender_first_names]' as sender_first_names,
'[db_quote $sender_last_name]' as sender_last_name,
parties.email,
(case acs_objects.object_type
when 'user' then
(select first_names
from persons
where person_id = parties.party_id)
when 'group' then
(select group_name
from groups
where group_id = parties.party_id)
when 'rel_segment' then
(select segment_name
from rel_segments
where segment_id = parties.party_id)
else '' end) as first_names,
(case acs_objects.object_type
when 'user' then
(select last_name
from persons
where person_id = parties.party_id)
else '' end) as last_name,
'[db_quote $community_name]' as community_name,
'[db_quote $community_url]' as community_url
from party_approved_member_map,
parties,
acs_objects
where party_approved_member_map.party_id = $segment_id
and party_approved_member_map.member_id <> $segment_id
and party_approved_member_map.member_id = parties.party_id
and parties.party_id = acs_objects.object_id
and parties.party_id in (
select survey_response__initial_user_id(response_id)
from survey_responses_latest where survey_id=$survey_id)
select '[db_quote $sender_email]' as from_addr,
'[db_quote $sender_first_names]' as sender_first_names,
'[db_quote $sender_last_name]' as sender_last_name,
parties.email,
(case acs_objects.object_type
when 'user' then
(select first_names
from persons
where person_id = parties.party_id)
when 'group' then
(select group_name
from groups
where group_id = parties.party_id)
when 'rel_segment' then
(select segment_name
from rel_segments
where segment_id = parties.party_id)
else '' end) as first_names,
(case acs_objects.object_type
when 'user' then
(select last_name
from persons
where person_id = parties.party_id)
else '' end) as last_name,
'[db_quote $community_name]' as community_name,
'[db_quote $community_url]' as community_url
from party_approved_member_map,
parties,
acs_objects
where party_approved_member_map.party_id = $segment_id
and party_approved_member_map.member_id <> $segment_id
and party_approved_member_map.member_id = parties.party_id
and parties.party_id = acs_objects.object_id
and parties.party_id not in (
select survey_response__initial_user_id(response_id)
from survey_responses_latest where survey_id=$survey_id)
select '[db_quote $sender_email]' as from_addr,
'[db_quote $sender_first_names]' as sender_first_names,
'[db_quote $sender_last_name]' as sender_last_name,
parties.email
from parties
where parties.party_id in (
select survey_response__initial_user_id(response_id)
from survey_responses_latest where survey_id=$survey_id)