(SELECT GetEmailsinv_apps(:CUSTOMER_TRX_ID) email_address,
oha.header_id,
hcp.contact_point_type,
trx.CUSTOMER_TRX_ID
FROM ont.oe_order_headers_all oha,
ar.ra_customer_trx_lines_all trx,
ar.hz_cust_account_roles hcar,
ar.hz_org_contacts hoc,
ar.hz_relationships hrel,
ar.hz_parties hp2,
ar.hz_contact_points hcp
WHERE oha.sold_to_contact_id = hcar.cust_account_role_id(+)
AND hcar.party_id = hrel.party_id(+)
AND hcar.role_type(+) = 'CONTACT'
AND hoc.party_relationship_id(+) = hrel.relationship_id
AND hrel.directional_flag(+) = 'F'
AND hrel.subject_table_name(+) = 'HZ_PARTIES'
AND hrel.object_table_name(+) = 'HZ_PARTIES'
AND hrel.party_id = hp2.party_id(+)
AND hcp.contact_point_type(+) = 'EMAIL'
AND hcp.contact_point_purpose = 'INV'
AND hcp.owner_table_id(+) = hp2.party_id
AND hcp.owner_table_name(+) = 'HZ_PARTIES'
AND hcp.status(+) = 'A'
AND trx.SALES_ORDER = oha.ORDER_NUMBER
--ADDED BY JOSH FOR TESTING
and trx.customer_trx_id = :customer_trx_id --5063 --in (4834, 5063)
--AND rownum = 1
&lp_print_only ---Added by SRS2 11/07/08
)
union
(SELECT null email_address,
null header_id,
'PRINT' contact_point_type,
null CUSTOMER_TRX_ID
from dual
where
( SELECT hcp.email_address
FROM ont.oe_order_headers_all oha,
ar.ra_customer_trx_lines_all trx,
ar.hz_cust_account_roles hcar,
ar.hz_org_contacts hoc,
ar.hz_relationships hrel,
ar.hz_parties hp2,
ar.hz_contact_points hcp
WHERE oha.sold_to_contact_id = hcar.cust_account_role_id(+)
AND hcar.party_id = hrel.party_id(+)
AND hcar.role_type(+) = 'CONTACT'
AND hoc.party_relationship_id(+) = hrel.relationship_id
AND hrel.directional_flag(+) = 'F'
AND hrel.subject_table_name(+) = 'HZ_PARTIES'
AND hrel.object_table_name(+) = 'HZ_PARTIES'
AND hrel.party_id = hp2.party_id(+)
AND hcp.contact_point_type(+) = 'EMAIL'
AND hcp.contact_point_purpose = 'INV'
AND hcp.owner_table_id(+) = hp2.party_id
AND hcp.owner_table_name(+) = 'HZ_PARTIES'
AND hcp.status(+) = 'A'
AND trx.SALES_ORDER = oha.ORDER_NUMBER
--ADDED BY JOSH FOR TESTING
and trx.customer_trx_id = :customer_trx_id --5063 -- in (4834, 5063)
AND rownum = 1
&lp_print_only ---Added by SRS2 11/07/08
) is null )
oha.header_id,
hcp.contact_point_type,
trx.CUSTOMER_TRX_ID
FROM ont.oe_order_headers_all oha,
ar.ra_customer_trx_lines_all trx,
ar.hz_cust_account_roles hcar,
ar.hz_org_contacts hoc,
ar.hz_relationships hrel,
ar.hz_parties hp2,
ar.hz_contact_points hcp
WHERE oha.sold_to_contact_id = hcar.cust_account_role_id(+)
AND hcar.party_id = hrel.party_id(+)
AND hcar.role_type(+) = 'CONTACT'
AND hoc.party_relationship_id(+) = hrel.relationship_id
AND hrel.directional_flag(+) = 'F'
AND hrel.subject_table_name(+) = 'HZ_PARTIES'
AND hrel.object_table_name(+) = 'HZ_PARTIES'
AND hrel.party_id = hp2.party_id(+)
AND hcp.contact_point_type(+) = 'EMAIL'
AND hcp.contact_point_purpose = 'INV'
AND hcp.owner_table_id(+) = hp2.party_id
AND hcp.owner_table_name(+) = 'HZ_PARTIES'
AND hcp.status(+) = 'A'
AND trx.SALES_ORDER = oha.ORDER_NUMBER
--ADDED BY JOSH FOR TESTING
and trx.customer_trx_id = :customer_trx_id --5063 --in (4834, 5063)
--AND rownum = 1
&lp_print_only ---Added by SRS2 11/07/08
)
union
(SELECT null email_address,
null header_id,
'PRINT' contact_point_type,
null CUSTOMER_TRX_ID
from dual
where
( SELECT hcp.email_address
FROM ont.oe_order_headers_all oha,
ar.ra_customer_trx_lines_all trx,
ar.hz_cust_account_roles hcar,
ar.hz_org_contacts hoc,
ar.hz_relationships hrel,
ar.hz_parties hp2,
ar.hz_contact_points hcp
WHERE oha.sold_to_contact_id = hcar.cust_account_role_id(+)
AND hcar.party_id = hrel.party_id(+)
AND hcar.role_type(+) = 'CONTACT'
AND hoc.party_relationship_id(+) = hrel.relationship_id
AND hrel.directional_flag(+) = 'F'
AND hrel.subject_table_name(+) = 'HZ_PARTIES'
AND hrel.object_table_name(+) = 'HZ_PARTIES'
AND hrel.party_id = hp2.party_id(+)
AND hcp.contact_point_type(+) = 'EMAIL'
AND hcp.contact_point_purpose = 'INV'
AND hcp.owner_table_id(+) = hp2.party_id
AND hcp.owner_table_name(+) = 'HZ_PARTIES'
AND hcp.status(+) = 'A'
AND trx.SALES_ORDER = oha.ORDER_NUMBER
--ADDED BY JOSH FOR TESTING
and trx.customer_trx_id = :customer_trx_id --5063 -- in (4834, 5063)
AND rownum = 1
&lp_print_only ---Added by SRS2 11/07/08
) is null )
No comments:
Post a Comment