楼主: vvyjp

oracle ERP的SQL脚本

[复制链接]
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
11#
 楼主| 发表于 2007-2-20 11:47 | 只看该作者
从总帐追溯到发票

SELECT   je_header_id, je_line_num, trx_class_name, trx_type_name, trx_number_displayed, trx_date,
         comments, doc_sequence_name, doc_sequence_value, acct_line_type_name,
         currency_code, entered_dr, entered_cr, accounted_dr, accounted_cr,
         taxable_entered_dr, taxable_entered_cr, taxable_accounted_dr,
         taxable_accounted_cr, currency_conversion_date,
         currency_user_conversion_type, currency_conversion_rate,
         third_party_name, third_party_number, third_party_sub_name,
         accounting_date, gl_transfer_status_name, transfer_system_name,
         gl_transfer_from_to_name, accounting_complete_name,
         ae_line_reference, tax_code, accounting_rule_name, tax_exempt_number,
         trx_line_type_name, trx_line_number, trx_detail_line_number,
         trx_quantity, sales_order_number, salesrep_name, tax_rate,
         unit_selling_price, trx_uom, trx_source_name, asset_number,
         asset_description, asset_book_type_code, accounting_event_number,
         accounting_event_type, accounting_event_type_name,
         accounting_line_number, aeh_accounting_error_name,
         ael_accounting_error_name, user_je_category_name,
         transfer_status_detail_name, application_date,
         applied_to_trx_hdr_currency, applied_to_trx_hdr_date,
         applied_to_trx_hdr_id, applied_to_trx_hdr_number_c,
         applied_to_trx_hdr_number_disp, applied_to_trx_hdr_table,
         applied_to_trx_line_number, applied_to_trx_line_type,
         applied_to_trx_line_type_name, ar_activity_name,
         ar_adjustment_creation_type, ar_adjustment_type, bank_account_name,
         bank_statement_doc_seq_id, bank_statement_doc_seq_name,
         bank_statement_doc_seq_value, bank_statement_line_number,
         bank_statement_number, bom_department_code, bom_department_name,
         chargeback_number, cost_element_id, cost_element_name,
         distribution_set_name, gl_batch_id, inventory_item_locator_id,
         inventory_item_locator_name, inventory_item_revision,
         item_description, inventory_organization_code,
         inventory_organization_id, cost_type_id, cost_type_name,
         mfg_operation_seq_num, payment_cleared_date, payment_date,
         payment_deposit_date, payment_number, payment_recon_currency,
         po_line_num, po_order_number, po_order_release_num, price_override,
         po_order_shipment_num, po_order_distribution_num, po_order_type,
         rcv_receipt_num, rcv_shipment_header_id, reversal_comments,
         reversal_date, subinventory, trx_hdr_currency, trx_reason_name,
         trx_source_type_id, trx_source_type_name, unit_cost, unit_price,
         wip_assembly, wip_basis, wip_flow_schedule_number, wip_job_id,
         wip_job_name, wip_line_code, wip_line_id, wip_resource_id,
         wip_resource_name, wip_resource_seq_num, pa_employee_num,
         pa_employee_name, pa_supplier_num, pa_supplier_name, pa_project_num,
         pa_project_name, pa_task_num, pa_task_name, pa_ei_ev_org,
         pa_nl_resource_org, pa_nl_resource, pa_ei_ev_type, pa_event_num,
         pa_quantity, pa_uom, pa_period_date, pa_gl_transfer_date,
         pa_customer_number, pa_customer_name, pa_agreement_num,
         pa_accrue_thru_date, pa_dri_number, pa_trans_id, pa_line_number,
         prvdr_organization_name, recvr_organization_name, prvdr_ou_name,
         recvr_ou_name, cc_type_name, cc_proc_method_name, application_id,
          asset_id, asset_category_id,
         asset_key_ccid, code_combination_id, inventory_item_id,
         set_of_books_id, org_id, trx_class, trx_type_n, trx_type_c,
         trx_number_n, trx_number_c, doc_sequence_id, trx_hdr_table,
         trx_hdr_id, acct_line_type, currency_conversion_type,
         third_party_type, third_party_id, third_party_sub_id,
         gl_transfer_status, source_table, source_id, ael_table, ael_id,
         aeh_accounting_error_code, ael_accounting_error_code, je_category,
         trx_line_type, trx_source_id, last_update_date, last_updated_by,
         creation_date, created_by, last_update_login, request_id,
         program_application_id, program_id, program_update_date,
         pa_project_id, pa_view_labor_cost
    FROM xla_ap_inv_ael_gl_v xla_ael_gl_v
   WHERE je_header_id = 1512
     AND je_line_num = 2080
ORDER BY trx_hdr_id, accounting_event_number, accounting_line_number

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
12#
 楼主| 发表于 2007-2-20 11:47 | 只看该作者
从接收追溯到接收事务

SELECT   row_id, creation_date, created_by, last_update_date, last_updated_by,
         last_update_login, note_to_receiver, pll_note_to_receiver,
         rma_reference, transaction_id, interface_transaction_id,
         displayed_trans_type, transaction_type, transact_qty, transact_uom,
         transaction_date, item_rev, displayed_dest_type, deliver_to_location,
         deliver_to_person, subinventory, receipt_num, displayed_source_type,
         order_num, po_release, order_line, po_shipment, supplier,
         country_of_origin, supplier_site, source_doc_qty, source_doc_uom,
         vendor_item_num, vendor_lot_num, packing_slip, freight_carrier,
         bill_of_lading, reason, hazard, un_num, wip_entity_id, wip_line_id,
         wip_operation_seq_num, receipt_exception_flag, receiver, source_type,
         destination_type_code, item_id, category_id, ship_to_location_id,
         locator_id, supplier_id, supplier_site_id, shipment_header_id,
         shipment_line_id, req_header_id, req_line_id, po_header_id,
         po_line_id, po_line_location_id, po_distribution_id, po_release_id,
         shipment_num, displayed_source_doc_code, source_doc_code, item_desc,
         routing, comments, attribute_category, attribute1, attribute2,
         attribute3, attribute4, attribute5, attribute6, attribute7,
         attribute8, attribute9, attribute10, attribute11, attribute12,
         attribute13, attribute14, attribute15, currency_code,
         currency_conversion_type, currency_conversion_date,
         currency_conversion_rate, rate_type_display, oe_order_header_id,
         oe_order_num, oe_order_line_id, oe_order_line_num, customer_id,
         customer, customer_site_id, inspection_quality_code,
         secondary_quantity, secondary_unit_of_measure
    FROM rcv_vrc_txs_v
   WHERE EXISTS (
            SELECT 1
              FROM rcv_shipment_lines rsl
             WHERE rsl.to_organization_id = 87
               AND rcv_vrc_txs_v.shipment_header_id = rsl.shipment_header_id)
     AND -1 = -1
     AND (rcv_vrc_txs_v.organization_id = 87)
     AND (transaction_id = 10939)
ORDER BY transact_qty, displayed_trans_type DESC, transaction_date DESC

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
13#
 楼主| 发表于 2007-2-20 11:48 | 只看该作者
从发票追溯到接收

SELECT   destination_type_code, distribution_line_number, line_type, amount,
         vat_code, tax_code_id, tax_code_override_flag, tax_recovery_rate,
         tax_recoverable_flag, tax_recovery_override_flag, accounting_date,
         amount_includes_tax_flag, assets_tracking_flag, description,
         type_1099, income_tax_region, final_match_flag, quantity_invoiced,
         unit_price, po_number, po_line_number, po_line_location_number,
         po_distribution_number, receipt_number, project, task, award_id,
         expenditure_type, expenditure_organization_name,
         expenditure_item_date, pa_quantity, unit_of_measure,
         prepay_distribution_id, prepay_number, prepay_dist_number,
         prepay_amount_remaining, invoice_includes_prepay_flag, stat_amount,
         awt_group_name, awt_creation_method, posted_status_disp,
         start_expense_date, merchant_document_number, merchant_name,
         merchant_tax_reg_number, merchant_taxpayer_id, merchant_reference,
         country_of_supply, ussgl_transaction_code, last_update_date,
         creation_date, row_id, accrual_posted_flag,
         accts_pay_code_combination_id, assets_addition_flag,
         invoice_distribution_id, attribute14, attribute1, attribute10,
         attribute11, attribute12, attribute13, attribute15, attribute2,
         attribute3, attribute4, attribute5, attribute6, attribute7,
         attribute8, attribute9, attribute_category, awt_flag,
         awt_gross_amount, awt_group_id, awt_invoice_id, awt_origin_group_id,
         awt_tax_rate_id, base_amount, base_invoice_price_variance,
         base_quantity_variance, batch_id, cash_je_batch_id, cash_posted_flag,
         created_by, dist_code_combination_id, encumbered_flag, exchange_date,
         exchange_rate, exchange_rate_type, exchange_rate_variance,
         expenditure_organization_id, invoice_id, invoice_price_variance,
         je_batch_id, last_updated_by, last_update_login,
         line_type_lookup_code, match_status_flag, org_id, other_invoice_id,
         packet_id, parent_invoice_id, pa_addition_flag, period_name,
         posted_amount, posted_base_amount, posted_flag,
         po_accrue_on_receipt_flag, po_code_combination_id,
         po_distribution_id, price_var_code_combination_id,
         program_application_id, program_id, program_update_date,
         project_accounting_context, project_id, quantity_variance,
         rate_var_code_combination_id, reference_1, reference_2, request_id,
         reversal_flag, set_of_books_id, set_of_books_short_name, task_id,
         tax_calculated_flag, ussgl_trx_code_context, invoice_num,
         parent_invoice_num, batch_name, income_tax_region_name,
         posted_status, je_batch_name, cash_je_batch_name,
         chart_of_accounts_id, set_of_books_name, po_header_id, po_line_id,
         line_location_id, rcv_transaction_id, unit_meas_lookup_code,
         tax_type, matched_uom_lookup_code, parent_reversal_id,
         global_attribute_category, global_attribute1, global_attribute2,
         global_attribute3, global_attribute4, global_attribute5,
         global_attribute6, global_attribute7, global_attribute8,
         global_attribute9, global_attribute10, global_attribute11,
         global_attribute12, global_attribute13, global_attribute14,
         global_attribute15, global_attribute16, global_attribute17,
         global_attribute18, global_attribute19, global_attribute20
    FROM ap_invoice_distributions_v
   WHERE invoice_id = 14653
ORDER BY distribution_line_number,
         line_type,
         amount,
         DECODE (line_type_lookup_code, 'ITEM', 1, 'PREPAY', 3, 'AWT', 4, 2)

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
14#
 楼主| 发表于 2007-2-20 11:48 | 只看该作者
标准订单查询


select distinct h.po_header_id, m.segment1, l.item_description, d.quantity_ordered, d.quantity_delivered, d.quantity_billed, d.quantity_cancelled, p.last_name, v.vendor_name, h.comments, l.attribute1 from po.po_headers_all h, po.po_vendors v, po.po_lines_all l, inv.MTL_SYSTEM_ITEMS_B m, hr.per_all_people_f p, po.po_distributions_all d
where h.type_lookup_code = 'STANDARD' and h.approved_flag = 'Y' and  h.vendor_id = v.vendor_id and l.po_header_id = h.po_header_id and m.inventory_item_id = l.item_id and h.agent_id = p.person_id and d.po_header_id = h.po_header_id

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
15#
 楼主| 发表于 2007-2-20 11:49 | 只看该作者
PO发运与分配


SELECT   row_id, created_by, last_update_date, last_update_login,
         last_updated_by, po_num, release_num, release_type, revised_date,
         bill_to_location_id, agent_id, vendor_site_id, vendor_id,
         authorization_status, revision_num, doc_type_name, type_lookup_code,
         order_date, approved_date, currency_code, line_num, line_type,
         line_type_id, item_id, item_revision, category_id, item_description,
         unit_meas_lookup_code, vendor_product_num, contract_num,
         shipment_num, distribution_num, need_by_date, price_override,
         taxable_flag, matching_type, shipment_type, closed_code, closed_date,
         closed_by, po_distribution_id, po_header_id, po_release_id,
         po_line_id, line_location_id, set_of_books_id, code_combination_id,
         recovery_rate, quantity_ordered, creation_date, quantity_delivered,
         quantity_billed, quantity_cancelled, req_distribution_id, online_req,
         req_distribution_num, req_num, req_line_num, requisition_header_id,
         deliver_to_location_id, deliver_to_person_id, rate_date,
         amount_billed, rate, accrued_flag, encumbered_flag,
         encumbered_amount, gl_encumbered_date, gl_encumbered_period_name,
         gl_cancelled_date, destination_type_code,
         destination_organization_id, destination_subinventory, wip_entity_id,
         wip_operation_seq_num, wip_resource_seq_num,
         wip_repetitive_schedule_id, wip_line_id, bom_resource_id,
         budget_account_id, accrual_account_id, variance_account_id,
         project_id, task_id, end_item_unit_number, expenditure_type,
         expenditure_organization_id, gl_closed_date, accrue_on_receipt_flag,
         expenditure_item_date, attribute1, attribute2, attribute3,
         attribute4, attribute5, attribute6, attribute7, attribute8,
         attribute9, attribute10, attribute11, attribute12, attribute13,
         attribute14, attribute15, attribute_category, ussgl_transaction_code,
         acceptance_due_date, oke_contract_line_id,
         oke_contract_deliverable_id, vmi_flag
    FROM po_distributions_inq_v
   WHERE (   245 = agent_id
          OR EXISTS (
                SELECT 'This employee is in approval path of this doc'
                  FROM po_action_history poah2
                 WHERE poah2.employee_id + 0 = 245
                   AND poah2.object_type_code IN ('PO', 'PA')
                   AND poah2.object_id = po_header_id)
          OR (    ((type_lookup_code = 'STANDARD') AND (release_num IS NULL)
                  )
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR (    ((type_lookup_code = 'PLANNED') AND (release_num IS NULL))
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR (    release_type = 'BLANKET'
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR (    release_type = 'SCHEDULED'
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR ('N' = 'Y')
         )
     AND -1 = -1
     AND (po_header_id = 4827)
     AND (po_line_id = 7313)
     AND (line_location_id = 7863)
ORDER BY po_header_id DESC,
         release_num DESC,
         line_num,
         shipment_num,
         distribution_num

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
16#
 楼主| 发表于 2007-2-20 11:50 | 只看该作者
PO行

SELECT   row_id, created_by, last_update_date, last_update_login,
         last_updated_by, po_num, revised_date, approved_date,
         bill_to_location, bill_to_location_id, ship_to_location_id,
         ship_to_location, agent_id, vendor_site_code, vendor_site_id,
         vendor_name, vendor_id, vendor_contact, authorization_status,
         revision_num, doc_type_name, type_lookup_code, order_date,
         currency_code, terms_name, ship_via_lookup_code, rate_type,
         rate_date, rate, start_date, end_date, blanket_total_amount,
         note_to_receiver, confirming_order_flag, quote_vendor_quote_number,
         po_header_id, po_line_id, line_type_id, line_type, line_num,
         creation_date, item_id, qc_grade, item_revision, category_id,
         item_description, unit_meas_lookup_code, base_uom, secondary_uom,
         quantity_committed, committed_amount, expiration_date,
         allow_price_override_flag, not_to_exceed_price, unit_price, quantity,
         base_qty, secondary_qty, un_number_id, un_number, hazard_class_id,
         hazard_class, note_to_vendor, quote_num, from_header_id,
         quote_line_num, from_line_id, market_price, list_price_per_unit,
         unordered_flag, cancel_flag, cancelled_by, closed_by, cancel_date,
         cancel_reason, oke_contract_version_id, vendor_product_num,
         contract_num, tax_name, type_1099, capital_expense_flag,
         negotiated_by_preparer_flag, min_release_amount,
         price_type_lookup_code, closed_code, closed_date, closed_reason,
         transaction_reason_code, attribute1, attribute2, attribute3,
         attribute4, attribute5, attribute6, attribute7, attribute8,
         attribute9, attribute10, attribute11, attribute12, attribute13,
         attribute14, attribute15, attribute_category, ussgl_transaction_code,
         secondary_unit_of_measure, secondary_quantity, preferred_grade,
         auction_header_id, auction_display_number, auction_line_number,
         bid_number, bid_line_number, acceptance_due_date,
         oke_contract_header_id, header_fob_lookup_code,
         header_freight_terms_lc
    FROM po_lines_inq_v
   WHERE (   245 = agent_id
          OR EXISTS (
                SELECT 'This employee is in approval path of this doc'
                  FROM po_action_history poah2
                 WHERE poah2.employee_id + 0 = 245
                   AND poah2.object_type_code IN ('PO', 'PA')
                   AND poah2.object_id = po_header_id)
          OR (    type_lookup_code = 'STANDARD'
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR (    type_lookup_code = 'PLANNED'
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR (    type_lookup_code = 'BLANKET'
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR ('N' = 'Y')
         )
     AND -1 = -1
     AND (po_header_id = 4825)
ORDER BY po_header_id DESC, line_num

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
17#
 楼主| 发表于 2007-2-20 11:51 | 只看该作者
PO行费用

SELECT   row_id, created_by, last_update_date, last_update_login,
         last_updated_by, po_num, revised_date, approved_date,
         bill_to_location, bill_to_location_id, ship_to_location_id,
         ship_to_location, agent_id, vendor_site_code, vendor_site_id,
         vendor_name, vendor_id, vendor_contact, authorization_status,
         revision_num, doc_type_name, type_lookup_code, order_date,
         currency_code, terms_name, ship_via_lookup_code, rate_type,
         rate_date, rate, start_date, end_date, blanket_total_amount,
         note_to_receiver, confirming_order_flag, quote_vendor_quote_number,
         po_header_id, po_line_id, line_type_id, line_type, line_num,
         creation_date, item_id, qc_grade, item_revision, category_id,
         item_description, unit_meas_lookup_code, base_uom, secondary_uom,
         quantity_committed, committed_amount, expiration_date,
         allow_price_override_flag, not_to_exceed_price, unit_price, quantity,
         base_qty, secondary_qty, un_number_id, un_number, hazard_class_id,
         hazard_class, note_to_vendor, quote_num, from_header_id,
         quote_line_num, from_line_id, market_price, list_price_per_unit,
         unordered_flag, cancel_flag, cancelled_by, closed_by, cancel_date,
         cancel_reason, oke_contract_version_id, vendor_product_num,
         contract_num, tax_name, type_1099, capital_expense_flag,
         negotiated_by_preparer_flag, min_release_amount,
         price_type_lookup_code, closed_code, closed_date, closed_reason,
         transaction_reason_code, attribute1, attribute2, attribute3,
         attribute4, attribute5, attribute6, attribute7, attribute8,
         attribute9, attribute10, attribute11, attribute12, attribute13,
         attribute14, attribute15, attribute_category, ussgl_transaction_code,
         secondary_unit_of_measure, secondary_quantity, preferred_grade,
         auction_header_id, auction_display_number, auction_line_number,
         bid_number, bid_line_number, acceptance_due_date,
         oke_contract_header_id, header_fob_lookup_code,
         header_freight_terms_lc
    FROM po_lines_inq_v
   WHERE (   245 = agent_id
          OR EXISTS (
                SELECT 'This employee is in approval path of this doc'
                  FROM po_action_history poah2
                 WHERE poah2.employee_id + 0 = 245
                   AND poah2.object_type_code IN ('PO', 'PA')
                   AND poah2.object_id = po_header_id)
          OR (    type_lookup_code = 'STANDARD'
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR (    type_lookup_code = 'PLANNED'
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR (    type_lookup_code = 'BLANKET'
              AND (   ('PUBLIC' = 'PUBLIC')
                   OR (    'PUBLIC' = 'PURCHASING'
                       AND EXISTS (
                              SELECT 'this employee is an agent'
                                FROM po_agents poa
                               WHERE poa.agent_id = 245
                                 AND SYSDATE BETWEEN NVL
                                                       (poa.start_date_active,
                                                        SYSDATE
                                                       )
                                                 AND NVL (poa.end_date_active,
                                                          SYSDATE + 1
                                                         ))
                      )
                   OR (    'PUBLIC' = 'HIERARCHY'
                       AND 245 IN (
                              SELECT poeh.superior_id
                                FROM po_employee_hierarchies poeh
                               WHERE poeh.employee_id = agent_id
                                 AND poeh.position_structure_id =
                                                                 NVL ('-1',
                                                                      -1))
                      )
                  )
             )
          OR ('N' = 'Y')
         )
     AND -1 = -1
     AND (po_header_id = 4827)
ORDER BY po_header_id DESC, line_num

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
18#
 楼主| 发表于 2007-2-20 11:52 | 只看该作者
检查应收收款发生额

SELECT SUM(nvl(dist.amount_dr,0))-SUM(nvl(dist.amount_cr,0))
FROM ar_cash_receipt_history_all hist,
     ar_distributions_all dist
WHERE hist.cash_receipt_history_id = dist.source_id
--  AND hist.status = 'REVERSED'
  AND hist.gl_date BETWEEN TO_DATE('2004-04-29','yyyy-mm-dd') AND TO_DATE('2004-05-28','yyyy-mm-dd')
--  AND ABS(NVL(DIST.AMOUNT_DR,0)-NVL(DIST.AMOUNT_CR,0))=147300
--  AND HIST.CASH_RECEIPT_ID = 143283

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
19#
 楼主| 发表于 2007-2-20 11:54 | 只看该作者
检查应收收款核销额

SELECT cust.customer_number, cust.customer_name, cash.receipt_number,
       gcc.segment1 || '.' || gcc.segment2 || '.' || gcc.segment3 || '.' ||
       gcc.segment4 || '.' || gcc.segment5|| '.' || gcc.segmsegment6 || '.' || gcc.segmsegment7 ,
       ara.amount_applied, ara.status,ara.display
       --*/SUM(ara.amount_applied)
FROM ar_receivable_applications_all ara,
     gl_code_combinations gcc,
     ar_cash_receipts_all  cash,
     ra_customers cust
WHERE ara.org_id =
  AND cash.cash_receipt_id = ara.cash_receipt_id AND cash.pay_from_customer (+) = cust.customer_id
  AND gcc.code_combination_id = ara.code_combination_id

使用道具 举报

回复
论坛徽章:
135
奥运会纪念徽章:乒乓球
日期:2012-08-23 19:41:492014数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192010数据库技术大会纪念徽章
日期:2015-04-23 10:33:19马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
20#
 楼主| 发表于 2007-2-20 11:56 | 只看该作者
客户
select b.party_name

from hz_cust_acct_sites_all a,  hz_parties b, hz_cust_accounts c

where a.org_id=260 and
      a.cust_account_id = c.cust_account_id and
      c.party_id = b.party_id

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表