Advertisement
Guest User

ui.get_report_messages_list(in_dt_beg character varying, in_

a guest
Jan 23rd, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.77 KB | None | 0 0
  1.  
  2. 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
  3. FROM mgw.push_msg pm LEFT JOIN mgw.push_msg_destination pmd
  4. ON pm.message_id = pmd.message_id
  5. LEFT JOIN mgw.push_msg_error pme ON pm.message_id = pme.message_id
  6. JOIN ccom.message_sending_log msl ON msl.mgw_message_id = pm.message_id
  7. JOIN ccom.transactions ct ON ct.id = msl.transaction_id
  8. JOIN ccom.operation_types ot ON ot.code = ct.operation_type
  9. 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')
  10.  
  11. UNION ALL
  12. 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
  13. FROM mgw.sms_msg pm LEFT JOIN mgw.sms_msg_destination pmd
  14. ON pm.message_id = pmd.message_id
  15. LEFT JOIN mgw.sms_msg_error pme ON pm.message_id = pme.message_id
  16. JOIN ccom.message_sending_log msl ON msl.mgw_message_id = pm.message_id
  17. JOIN ccom.transactions ct ON ct.id = msl.transaction_id
  18. JOIN ccom.operation_types ot ON ot.code = ct.operation_type
  19. 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')
  20. UNION ALL
  21. 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
  22. FROM mgw.email_msg_content pm LEFT JOIN mgw.email_msg_destination pmd
  23. ON pm.message_id = pmd.message_id
  24. LEFT JOIN mgw.email_msg_error pme ON pm.message_id = pme.message_id
  25. JOIN ccom.message_sending_log msl ON msl.mgw_message_id = pm.message_id
  26. JOIN ccom.transactions ct ON ct.id = msl.transaction_id
  27. JOIN ccom.operation_types ot ON ot.code = ct.operation_type
  28. 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')
  29. UNION ALL
  30. SELECT smpp.message_id, smpp.message_content, smpp.contact destination, 'smpp' channel_type, NULL description, smpp.accepted dt, smpp.STATUS, '' error_message, '' operation_type
  31. FROM (
  32.  SELECT message_id,message_content, contact, accepted,STATUS, processing_batch, port,user_name, alt_operation_type ,udh_key,udh_num,udh_size
  33.  FROM smpp.smpp_message
  34.  WHERE udh_key IS NULL
  35.  UNION ALL
  36.  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
  37.  FROM smpp.smpp_message
  38.  WHERE udh_key IS NOT NULL
  39.  GROUP BY udh_key, contact, port,user_name, alt_operation_type
  40.  ) smpp
  41.  LEFT JOIN ccom.message_log cml ON cml.message_id = smpp.message_id
  42. 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