Monday, 20 May 2013

11i and R12 bank query

 R 12

SELECT --decode (instr(chk.CHECK_NUMBER,',',1,1),0,chk.CHECK_NUMBER,'"' || chk.CHECK_NUMBER || '"') PAYMENT_ID
              TRIM(decode (instr(pv.segment1 || '-' || pvs.vendor_site_code,',',1,1),0,pv.segment1 || '-' || pvs.vendor_site_code,'"' || pv.segment1 || '-' || pvs.vendor_site_code || '"')) VENDOR_ID
            --    TRIM(decode (instr(pv.segment1 || '~' || pvs.vendor_site_code,',',1,1),0,pv.segment1 || '~' || pvs.vendor_site_code,'"' || pv.segment1 || '~' || pvs.vendor_site_code || '"')) VENDOR_ID
             --, decode (instr(chk.VENDOR_NAME,',',1,1),0,chk.VENDOR_NAME,'"' || chk.VENDOR_NAME || '"') VENDOR_NAME
             --, NULL po_number
             --, NULL payment_id2
             --, NULL comments
             --, NULL Requester_login
             , TRIM(ai.invoice_num) Line_item_remit_comment_1
             --, NULL item_quantity
--             , NULL Line_item_remit_comment_2
             , TRIM(to_char(ai.invoice_date, 'MM/DD/RRRR'))    Line_item_remit_comment_2
             , TRIM(decode (instr(ai.invoice_amount,',',1,1),0,ai.invoice_amount,'"' || ai.invoice_amount || '"'))  item_unit_price
             , ai.invoice_id
  FROM   ap_checks_all chk,
         CE_PAYMENT_DOCUMENTS acs,
         CE_BANK_ACCOUNTS bka,
         CE_BANK_BRANCHES_V bkb,
         ap_suppliers pv,
         ap_invoice_payments_all aip,
         ap_invoices_all ai,
         AP_SUPPLIER_SITES_ALL pvs
 WHERE       2 = 2
         AND chk.PAYMENT_DOCUMENT_ID = acs.PAYMENT_DOCUMENT_ID
         AND acs.INTERNAL_BANK_ACCOUNT_ID = bka.bank_account_id
         AND bka.bank_branch_id = bkb.BRANCH_PARTY_ID
         AND chk.VENDOR_ID = pv.vendor_id
         AND aip.check_id = chk.check_id
         AND aip.invoice_id = ai.invoice_id
         AND pvs.vendor_id = pv.vendor_id
         AND pvs.vendor_site_code = chk.vendor_site_code
         AND chk.STATUS_LOOKUP_CODE = 'NEGOTIABLE'
         AND bkb.bank_branch_name = 'INTERNAL'

11i

SELECT --decode (instr(chk.CHECK_NUMBER,',',1,1),0,chk.CHECK_NUMBER,'"' || chk.CHECK_NUMBER || '"') PAYMENT_ID
              TRIM(decode (instr(pv.segment1 || '-' || pvs.vendor_site_code,',',1,1),0,pv.segment1 || '-' || pvs.vendor_site_code,'"' || pv.segment1 || '-' || pvs.vendor_site_code || '"')) VENDOR_ID
            --    TRIM(decode (instr(pv.segment1 || '~' || pvs.vendor_site_code,',',1,1),0,pv.segment1 || '~' || pvs.vendor_site_code,'"' || pv.segment1 || '~' || pvs.vendor_site_code || '"')) VENDOR_ID
             --, decode (instr(chk.VENDOR_NAME,',',1,1),0,chk.VENDOR_NAME,'"' || chk.VENDOR_NAME || '"') VENDOR_NAME
             --, NULL po_number
             --, NULL payment_id2
             --, NULL comments
             --, NULL Requester_login
             , TRIM(ai.invoice_num) Line_item_remit_comment_1
             --, NULL item_quantity
--             , NULL Line_item_remit_comment_2
             , TRIM(to_char(ai.invoice_date, 'MM/DD/RRRR'))    Line_item_remit_comment_2
             , TRIM(decode (instr(ai.invoice_amount,',',1,1),0,ai.invoice_amount,'"' || ai.invoice_amount || '"'))  item_unit_price
             , ai.invoice_id
          FROM ap_bank_branches bkb
             , ap_bank_accounts bka
             , ap_checks chk
             , po_vendors pv
             , ap_invoice_payments aip
             , ap_invoices ai
             , po_vendor_sites pvs
             , ap_check_stocks acs
         WHERE 1 = 1
           AND bkb.BANK_BRANCH_ID = bka.BANK_BRANCH_ID
           AND bka.bank_account_id = chk.bank_account_id
           AND chk.check_stock_id    = acs.check_stock_id
           AND acs.bank_account_id  = bka.bank_account_id
           AND chk.VENDOR_ID = pv.vendor_id
           AND aip.check_id = chk.check_id
           AND aip.invoice_id = ai.invoice_id
           AND pvs.vendor_id = pv.vendor_id
           AND pvs.vendor_site_code = chk.vendor_site_code
           AND chk.STATUS_LOOKUP_CODE = 'NEGOTIABLE'
           AND bka.account_type = 'INTERNAL'

No comments:

Post a Comment