Saturday, 21 March 2015

Document Sequences Inventory Query

/* Formatted on 2015/03/21 15:01 (Formatter Plus v4.8.8) */
SELECT jrd.registration_num, jrd.effective_from, jrd.effective_to,
       hao.NAME organization_name, hl.description location_name, jl.meaning organization_type,
       (CASE
           WHEN jrds.document_class = 'UD'
              THEN 'Unregistered - Default'
           WHEN jrds.document_class = 'D'
              THEN 'Default'
           WHEN jrds.document_class = 'O'
              THEN 'Order'
        END
       ) document_class,  (case when ott.name is null THEN 'Default' else ott.name end) Document_type_name ,
       jrds.start_number, jrds.current_number
  FROM jai_rgm_doc_seq_hdrs jrd,
       jai_rgm_doc_seq_dtls jrds,
       hr_all_organization_units hao,
       hr_locations hl ,
       oe_transaction_types_tl ott ,
       ja_lookups jl
 WHERE jrd.registration_num = nvl(:P_registration_num ,jrd.registration_num ) --'06291922190'
   AND TRUNC (jrd.effective_from) BETWEEN :p_from_date AND :p_to_date
   AND jrds.rgm_document_seq_id = jrd.rgm_document_seq_id
   AND hao.organization_id = jrd.party_id
   AND hl.location_id = jrd.party_site_id
   and ott.transaction_type_id(+) = jrds.DOCUMENT_CLASS_TYPE_ID
   and jrd.ORGANIZATION_TYPE = jl.lookup_code

No comments:

Post a Comment