Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT pm.message_id, pm.message_content,pmd.destination , msl.channel_type ,ot.description, msl.ts dt, msl.STATUS,pme.error_message,ot.description operation_type
- FROM mgw.push_msg pm LEFT JOIN mgw.push_msg_destination pmd
- ON pm.message_id = pmd.message_id
- LEFT JOIN mgw.push_msg_error pme ON pm.message_id = pme.message_id
- JOIN ccom.message_sending_log msl ON msl.mgw_message_id = pm.message_id
- JOIN ccom.transactions ct ON ct.id = msl.transaction_id
- JOIN ccom.operation_types ot ON ot.code = ct.operation_type
- WHERE msl.ts>=to_date(in_dt_beg,'MM/DD/YYYY') AND msl.ts<(to_date(in_dt_end,'MM/DD/YYYY')+ INTERVAL '1 day')
- UNION ALL
- SELECT pm.message_id, pm.message_content,pmd.destination , msl.channel_type ,ot.description, msl.ts dt, msl.STATUS,pme.error_message,ot.description operation_type
- FROM mgw.sms_msg pm LEFT JOIN mgw.sms_msg_destination pmd
- ON pm.message_id = pmd.message_id
- LEFT JOIN mgw.sms_msg_error pme ON pm.message_id = pme.message_id
- JOIN ccom.message_sending_log msl ON msl.mgw_message_id = pm.message_id
- JOIN ccom.transactions ct ON ct.id = msl.transaction_id
- JOIN ccom.operation_types ot ON ot.code = ct.operation_type
- WHERE msl.ts>=to_date(in_dt_beg,'MM/DD/YYYY') AND msl.ts<(to_date(in_dt_end,'MM/DD/YYYY')+ INTERVAL '1 day')
- UNION ALL
- SELECT pm.message_id, pm.message_content,pmd.destination , msl.channel_type ,ot.description, msl.ts dt, msl.STATUS,pme.error_message,ot.description operation_type
- FROM mgw.email_msg_content pm LEFT JOIN mgw.email_msg_destination pmd
- ON pm.message_id = pmd.message_id
- LEFT JOIN mgw.email_msg_error pme ON pm.message_id = pme.message_id
- JOIN ccom.message_sending_log msl ON msl.mgw_message_id = pm.message_id
- JOIN ccom.transactions ct ON ct.id = msl.transaction_id
- JOIN ccom.operation_types ot ON ot.code = ct.operation_type
- WHERE msl.ts>=to_date(in_dt_beg,'MM/DD/YYYY') AND msl.ts<(to_date(in_dt_end,'MM/DD/YYYY')+ INTERVAL '1 day')
- UNION ALL
- SELECT smpp.message_id, smpp.message_content, smpp.contact destination, 'smpp' channel_type, NULL description, smpp.accepted dt, smpp.STATUS, '' error_message, '' operation_type
- FROM (
- SELECT message_id,message_content, contact, accepted,STATUS, processing_batch, port,user_name, alt_operation_type ,udh_key,udh_num,udh_size
- FROM smpp.smpp_message
- WHERE udh_key IS NULL
- UNION ALL
- SELECT string_agg(message_id,','),string_agg(message_content, '' ORDER BY udh_num), contact,MIN(accepted),MIN(STATUS),NULL, port,user_name, alt_operation_type,udh_key,NULL,NULL
- FROM smpp.smpp_message
- WHERE udh_key IS NOT NULL
- GROUP BY udh_key, contact, port,user_name, alt_operation_type
- ) smpp
- LEFT JOIN ccom.message_log cml ON cml.message_id = smpp.message_id
- WHERE cml.id IS NULL AND smpp.accepted>=to_date(in_dt_beg,'MM/DD/YYYY') AND smpp.accepted<(to_date(in_dt_end,'MM/DD/YYYY')+ INTERVAL '1 day');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement