Friday, 24 January 2025

Oracle SQL Queries related to the Suppliers Data Model in Oracle Fusion

Here are some of the common SQL queries related to the Supplier Model in Oracle Fusion, involving  tables typically used for supplier data 

 Supplier profiles, 

 Supplier addresses, 

 Supplier Contacts

 Supplier Sites

 and data related to payments

1. SQL Query to List All Suppliers


SELECT vendor_id, vendor_name, vendor_number, creation_date, last_update_date
FROM po_vendors;

2. SQL Query to Find Supplier Details by Name or Number


SELECT vendor_id, vendor_name, vendor_number, vendor_type_lookup_code, enabled_flag, creation_date FROM po_vendors WHERE UPPER(vendor_name) LIKE '%SUPPLIER_NAME%' -- Replace 'SUPPLIER_NAME' with your search keyword OR vendor_number = 'SUPPLIER_NUMBER'; -- Replace 'SUPPLIER_NUMBER' with your number

3. SQL Query to Retrieve Supplier Sites

SELECT vendor_site_id, vendor_id, vendor_site_code, address_line1, city, state, postal_code, country
FROM po_vendor_sites_all WHERE vendor_id = :VENDOR_ID; -- Replace ':VENDOR_ID' with the supplier ID

4. SQL Query to List Supplier Contacts

SELECT vendor_contact_id, vendor_id, first_name, last_name, email_address, phone_number
FROM po_vendor_contacts WHERE vendor_id = :VENDOR_ID; -- Replace ':VENDOR_ID' with the supplier ID

5. SQL Query to Get Supplier Site Payment Details


SELECT vendor_site_id, payment_method_lookup_code, payment_currency_code, bank_account_num, bank_name FROM po_vendor_sites_all WHERE vendor_id = :VENDOR_ID; -- Replace ':VENDOR_ID' with the supplier ID

6. SQL Query to List Supplier Payment Methods


SELECT vendor_id, vendor_name, payment_method_lookup_code FROM po_vendors WHERE payment_method_lookup_code IS NOT NULL;

7. SQL Query to Find Active Suppliers


SELECT vendor_id, vendor_name, enabled_flag, creation_date FROM po_vendors WHERE enabled_flag = 'Y';

8. SQL Query to List All Bank Accounts Associated with Suppliers


SELECT ext_bank_account_id, bank_account_name, bank_account_num, currency_code, vendor_id FROM iby_ext_bank_accounts WHERE party_type_lookup_code = 'SUPPLIER';

9. SQL Query to Get Supplier Invoices


SELECT invoice_id, invoice_num, invoice_date, invoice_amount, payment_status_flag FROM ap_invoices_all WHERE vendor_id = :VENDOR_ID; -- Replace ':VENDOR_ID' with the supplier ID

10. SQL Query to Find Purchase Orders by Supplier


SELECT po_header_id, segment1 AS po_number, type_lookup_code, creation_date, total_amount FROM po_headers_all WHERE vendor_id = :VENDOR_ID; -- Replace ':VENDOR_ID' with the supplier ID

11. SQL Query to Find Supplier Purchase Agreements


SELECT agreement_id, vendor_id, agreement_type, status, start_date, end_date, total_amount FROM po_agreements WHERE vendor_id = :VENDOR_ID; -- Replace ':VENDOR_ID' with the supplier ID

12. SQL Query to List Suppliers with No Recent Activity


SELECT vendor_id, vendor_name, last_update_date FROM po_vendors WHERE last_update_date < ADD_MONTHS(SYSDATE, -6); -- Suppliers with no updates in the last 6 months

13. SQL Query to Retrieve Supplier Category Assignments


SELECT pac.vendor_id, pv.vendor_name, pac.category_id, msc.segment1 AS category FROM po_assign_categories pac JOIN po_vendors pv ON pac.vendor_id = pv.vendor_id JOIN mtl_categories_b msc ON pac.category_id = msc.category_id;

14. SQL Query to List Suppliers by Country


SELECT pv.vendor_id, pv.vendor_name, pvsa.country FROM po_vendors pv JOIN po_vendor_sites_all pvsa ON pv.vendor_id = pvsa.vendor_id WHERE pvsa.country = 'USA'; -- Replace 'USA' with your desired country

15. SQL Query to Find Suppliers with Specific Payment Terms


SELECT pv.vendor_id, pv.vendor_name, pvsa.payment_terms_id, hl.meaning AS payment_terms FROM po_vendors pv JOIN po_vendor_sites_all pvsa ON pv.vendor_id = pvsa.vendor_id JOIN hr_lookups hl ON pvsa.payment_terms_id = hl.lookup_code WHERE hl.meaning = 'Net 30'; -- Replace 'Net 30' with your payment terms

Key Oracle fusion tables in Supplier Model

  • PO_VENDORS: Stores supplier header information.
  • PO_VENDOR_SITES_ALL: Stores supplier site details.
  • PO_VENDOR_CONTACTS: Contains supplier contact information.
  • IBY_EXT_BANK_ACCOUNTS: Stores external bank account information for suppliers.
  • AP_INVOICES_ALL: Holds invoice details.
  • PO_HEADERS_ALL: Stores purchase order information.
  • PO_AGREEMENTS: Contains blanket or contract purchase agreement details.

Common Oracle SQL Queries to fetch the database table in Oracle fusion

Here are some of the common Oracle SQL queries to retrieve metadata in Oracle databases, including table details, columns, constraints, indexes, and more. 

These queries are especially useful when working with Oracle Fusion to find the underlying table metadata information.

Note : These are the sample queries, please modify accordingly as per your requirements. 

1. SQL Query to list All Tables in a Schema

SELECT table_name
FROM all_tables WHERE owner = 'FUSION'; -- Replace 'FUSION' with the schema name

2. SQL Query to List All Columns in a Table

SELECT column_name, data_type, data_length
FROM all_tab_columns WHERE table_name = 'PER_ALL_PEOPLE_F'; -- Replace with your table name

3. SQL Query to Search for Tables with Specific Column Names

SELECT table_name, column_name
FROM all_tab_columns WHERE column_name LIKE '%PERSON_ID%'; -- Replace with the column keyword

4. SQL Query to View Primary Key Information

SELECT cols.table_name, cols.column_name, cons.constraint_name
FROM all_cons_columns cols JOIN all_constraints cons ON cols.constraint_name = cons.constraint_name WHERE cons.constraint_type = 'P' AND cols.table_name = 'PER_ALL_PEOPLE_F'; -- Replace with your table name

5. SQL Query to View Foreign Key Information


SELECT a.table_name, a.column_name, a.constraint_name,
c_pk.table_name AS referenced_table, c_pk.constraint_name AS referenced_constraint FROM all_cons_columns a JOIN all_constraints c ON a.constraint_name = c.constraint_name JOIN all_constraints c_pk ON c.r_constraint_name = c_pk.constraint_name WHERE c.constraint_type = 'R' AND a.table_name = 'PER_ALL_ASSIGNMENTS_F'; -- Replace with your table name

6. SQL Query to View All Indexes on a Table

SELECT index_name, column_name, uniqueness
FROM all_ind_columns WHERE table_name = 'PER_ALL_PEOPLE_F'; -- Replace with your table name

7. SQL Query to View Constraints on a Table

SELECT constraint_name, constraint_type, status
FROM all_constraints WHERE table_name = 'PER_ALL_PEOPLE_F'; -- Replace with your table name

8. SQL Query to Search for a Keyword in Table or Column Names

SELECT table_name, column_name
FROM all_tab_columns WHERE table_name LIKE '%PERSON%' OR column_name LIKE '%PERSON%';

9. SQL Query to List All Views in a Schema

SELECT view_name
FROM all_views WHERE owner = 'FUSION'; -- Replace with the schema name

10. SQL Query to View Dependencies of a Table

SELECT name, type, referenced_name, referenced_type
FROM all_dependencies WHERE name = 'PER_ALL_PEOPLE_F'; -- Replace with your table name

11. SQL Query to Identify Data Types and Lengths

SELECT column_name, data_type, data_length, data_precision, data_scale
FROM all_tab_columns WHERE table_name = 'PER_ALL_PEOPLE_F'; -- Replace with your table name

12. SQL Query to List All Synonyms in a Schema


SELECT synonym_name, table_owner, table_name
FROM all_synonyms WHERE owner = 'FUSION'; -- Replace with your schema name

13. SQL Query to Search Materialized Views

SELECT mview_name
FROM all_mviews WHERE owner = 'FUSION'; -- Replace with the schema name

14. SQL Query to Find Columns with Date Data Type


SELECT table_name, column_name FROM all_tab_columns WHERE data_type = 'DATE';

Oracle Metadata Tables

  • ALL_TABLES: Contains details about all tables accessible to the user.
  • ALL_TAB_COLUMNS: Stores metadata about all columns.
  • ALL_CONSTRAINTS: Contains information about constraints on tables.
  • ALL_VIEWS: Provides details on views.
  • ALL_SYNONYMS: Contains synonym information.

SQL Query to get all the tables in Oracle Fusion.

 Here is the sample query to get all the tables in Oracle fusion.


SELECT table_name

FROM all_tables

WHERE owner = 'FUSION';


SQL Query to get the Metadata details for the tables in Oracle Fusion

 Here is the sample query to get the metadata details for the Oracle tables.

Note : Please modify as per your requirements accordingly.

SELECT atc.table_name, atc.column_name, atc.*

FROM all_tab_columns atc

WHERE column_name LIKE '%EMPLOYEE%' OR column_name LIKE '%PERSON%';


Tables in Oracle HCM

 Oracle Fusion HCM (Human Capital Management) is a comprehensive suite of HR tools. 

Commonly Used HCM Tables

Here are some common examples of tables in Oracle Fusion HCM:

1. Core HR Tables

  • PER_ALL_PEOPLE_F: Holds person details like name, date of birth, and hire date.
  • PER_ALL_ASSIGNMENTS_F: Stores employee assignment details.
  • PER_GRADES_F: Contains information about grades.
  • PER_JOBS_F: Holds job information.

2. Workforce Structures

  • HR_ORGANIZATION_UNITS_F: Organizational unit details.
  • HR_ALL_POSITIONS_F: Information about positions.

3. Payroll Tables

  • PAY_PERSONAL_PAYMENT_METHODS_F: Stores employee payment methods.
  • PAY_PAYROLL_REL_ACTIONS: Information about payroll run actions.
  • PAY_RUN_RESULTS: Results of payroll runs.

4. Security and User Tables

  • FND_USER: Stores user account details.
  • FND_USER_RESPONSIBILITY: User responsibilities.

Wednesday, 22 January 2025

SQL Query to fetch the Employee Payroll information in Oracle Cloud Fusion - HCM

Here is the sample SQL Query for Oracle Fusion HCM.  These queries will help to retrieve the basic information related to the employee payroll information.

This is the basic query, use this table accordingly and modify as per your requirements. 

SQL Query :

SELECT 

    ppf.person_number,

    ppf.full_name,

    pap.assignment_number,

    ppa.payroll_name,

    ppa.element_entry_id,

    ppa.salary_amount,

    ppa.currency_code

FROM 

    pay_element_entries_f ppa

JOIN 

    per_all_assignments_f pap ON ppa.assignment_id = pap.assignment_id

JOIN 

    per_all_people_f ppf ON pap.person_id = ppf.person_id

WHERE 

    ppa.element_name = 'Salary'

    AND SYSDATE BETWEEN ppa.effective_start_date AND ppa.effective_end_date;



SQL Query to fetch the Employee Assignment Information in Oracle Cloud Fusion - HCM

 Here is the sample SQL Query for Oracle Fusion HCM.  These queries will help to retrieve the basic information related to the employee assignment information.

This is the basic query, use this table accordingly and modify as per your requirements. 

SQL Query :

SELECT 

    a.assignment_number,

    p.person_number,

    p.full_name,

    a.job_id,

    j.job_name,

    a.position_id,

    pos.position_name,

    a.department_id,

    d.department_name,

    a.location_id,

    loc.location_code AS location_name,

    a.hire_date,

    a.assignment_status_type

FROM 

    per_all_assignments_f a

JOIN 

    per_all_people_f p ON a.person_id = p.person_id

JOIN 

    per_jobs j ON a.job_id = j.job_id

JOIN 

    per_positions pos ON a.position_id = pos.position_id

JOIN 

    hr_organization_units d ON a.department_id = d.organization_id

JOIN 

    hr_locations loc ON a.location_id = loc.location_id

WHERE 

    SYSDATE BETWEEN a.effective_start_date AND a.effective_end_date;



SQL Query to fetch the Employee Information in Oracle Cloud Fusion - HCM

Here is the sample SQL Query for Oracle Fusion HCM.  These queries will help to retrieve the basic information related to the employee information.

Use this table accordingly and modify as per your requirements.

SQL Query : 


SELECT 

    per.person_number,

    per.full_name,

    per.email_address,

    per.phone_number,

    per.date_of_birth,

    per.effective_start_date AS start_date,

    per.national_identifier AS ssn,

    per.*

FROM 

    per_all_people_f per

WHERE 

    SYSDATE BETWEEN per.effective_start_date AND per.effective_end_date;



Saturday, 3 August 2024

SQL Queries for the Oracle fusion Project Management

 Here are some sample Oracle Fusion SQL queries for various aspects of project management:

1. Query to Retrieve Project Details

SELECT project_id,
project_name, project_number, project_status, start_date, end_date FROM pjf_projects_all WHERE project_status = 'APPROVED';

2. Query to Retrieve Task Details for a Specific Project

SELECT task_id,
task_name, task_number, task_status, start_date, end_date FROM pjf_tasks WHERE project_id = :project_id; -- Replace with the specific project ID

3. Query to Retrieve Expenditure Items for a Specific Project

SELECT expenditure_item_id,
expenditure_type, expenditure_date, amount FROM pjc_expenditure_items WHERE project_id = :project_id; -- Replace with the specific project ID

4. Query to Retrieve Budget Lines for a Specific Project

SELECT budget_version_id,
budget_line_id, budget_amount, budget_date FROM pjf_budget_lines WHERE project_id = :project_id; -- Replace with the specific project ID

5. Query to Retrieve Resource Assignments for a Specific Project

SELECT assignment_id,
resource_id, task_id, start_date, end_date FROM pjr_assignments WHERE project_id = :project_id; -- Replace with the specific project ID

6. Query to Retrieve Contract Details for a Specific Project

SELECT contract_id,
contract_number, contract_name, start_date, end_date, contract_amount FROM pjb_contracts_all WHERE project_id = :project_id; -- Replace with the specific project ID

7. Query to Retrieve Invoice Details for a Specific Project

SELECT invoice_id,
invoice_number, invoice_date, amount FROM pjb_invoices_all WHERE project_id = :project_id; -- Replace with the specific project ID

8. Query to Retrieve Cost Distribution Lines for a Specific Project

SELECT cost_distribution_line_id,
transaction_id, amount, distribution_date FROM pjc_cost_distribution_lines WHERE project_id = :project_id; -- Replace with the specific project ID

These sample queries can be tailored to specific needs by modifying the WHERE clause conditions or by adding more columns to the SELECT statement.

Note, please refer to the Oracle documentations for any changes to the latest release and the updates.

SQL Queries tables in Oracle Fusion Project Management

 In Oracle Fusion Project Management, several key tables store data related to various aspects of project management. These tables are integral for managing project finances, resources, and operations. Here are some of the key tables:

  1. Projects and Tasks

    • PJF_PROJECTS_ALL: Stores information about projects.
    • PJF_TASKS: Stores details of tasks associated with projects.
  2. Expenditures

    • PJC_EXPENDITURE_ITEMS: Holds expenditure item data.
    • PJC_EXPENDITURE_TYPES: Stores types of expenditures.
  3. Budgets and Forecasts

    • PJF_BUDGET_VERSIONS: Contains budget versions for projects.
    • PJF_BUDGET_LINES: Stores individual budget lines.
  4. Project Costing

    • PJC_COST_DISTRIBUTION_LINES: Contains cost distribution lines.
    • PJC_TRANSACTIONS: Stores project transaction details.
  5. Billing

    • PJB_INVOICES_ALL: Contains billing invoice data.
    • PJB_INVOICE_LINES_ALL: Stores invoice lines.
  6. Resources and Assignments

    • PJR_RESOURCES: Contains information about resources assigned to projects.
    • PJR_ASSIGNMENTS: Stores details of resource assignments to tasks.
  7. Contracts and Funding

    • PJB_CONTRACTS_ALL: Holds contract information.
    • PJB_FUNDING_DISTRIBUTIONS: Contains funding distribution details.
  8. Project Integration and Reporting

    • PJF_PROJECT_REPORTING: Stores data for project reporting purposes.
    • PJF_INTEGRATION_EVENTS: Contains integration event data for project management.

These tables are crucial for the functionality of Oracle Fusion Project Management, allowing users to manage projects comprehensively from budgeting and costing to billing and resource management.

Please refer to the Oracle documentations for any changes in the latest releases.

SQL Queries tables in Oracle Fusion Procurement

 In Oracle Fusion Procurement, several key tables store data related to purchasing, suppliers, purchase orders, and related procurement activities. Here’s an overview of some important tables in Oracle Fusion Procurement, along with sample SQL queries which will be able to leveraged and can retrieve data from these tables.

Key Tables in Oracle Fusion Procurement

  1. PO_HEADERS_ALL

    • Contains header information for purchase orders.
    • Key columns: PO_HEADER_ID, PO_NUMBER, VENDOR_ID, CREATION_DATE, STATUS, etc.
  2. PO_LINES_ALL

    • Stores line-level details for purchase orders.
    • Key columns: PO_LINE_ID, PO_HEADER_ID, LINE_ID, ITEM_ID, QUANTITY, UNIT_PRICE, etc.
  3. PO_DISTRIBUTIONS_ALL

    • Contains distribution information for purchase order lines.
    • Key columns: PO_DISTRIBUTION_ID, PO_LINE_ID, ACCOUNTING_DATE, DISTRIBUTION_AMOUNT, etc.
  4. PO_SUPPLIERS

    • Information about suppliers.
    • Key columns: SUPPLIER_ID, SUPPLIER_NAME, SUPPLIER_TYPE, STATUS, ADDRESS, etc.
  5. PO_DOCUMENTS

    • Stores documents related to purchase orders.
    • Key columns: DOCUMENT_ID, PO_HEADER_ID, DOCUMENT_TYPE, DOCUMENT_NAME, etc.
  6. PO_AGREEMENTS

    • Contains details about procurement agreements.
    • Key columns: AGREEMENT_ID, AGREEMENT_NUMBER, SUPPLIER_ID, START_DATE, END_DATE, etc.
  7. PO_AGREEMENT_LINES

    • Details of lines in procurement agreements.
    • Key columns: AGREEMENT_LINE_ID, AGREEMENT_ID, ITEM_ID, QUANTITY, PRICE, etc.
  8. PO_APPROVALS

    • Contains approval information for purchase orders.
    • Key columns: APPROVAL_ID, PO_HEADER_ID, APPROVAL_STATUS, APPROVER_ID, APPROVAL_DATE, etc.
  9. PO_RECEIPTS

    • Stores information about goods receipts against purchase orders.
    • Key columns: RECEIPT_ID, PO_HEADER_ID, RECEIPT_DATE, QUANTITY_RECEIVED, ITEM_ID, etc.
  10. PO_PAYMENTS

    • Contains details about payments made to suppliers.
    • Key columns: PAYMENT_ID, PO_HEADER_ID, PAYMENT_AMOUNT, PAYMENT_DATE, PAYMENT_STATUS, etc.

Sample SQL Queries

1. Retrieve Purchase Order Header Information

SELECT
p.PO_HEADER_ID, p.PO_NUMBER, p.VENDOR_ID, v.SUPPLIER_NAME, p.CREATION_DATE, p.STATUS FROM PO_HEADERS_ALL p JOIN PO_SUPPLIERS v ON p.VENDOR_ID = v.SUPPLIER_ID WHERE p.CREATION_DATE BETWEEN TO_DATE('2024-01-01', 'YYYY-MM-DD') AND TO_DATE('2024-12-31', 'YYYY-MM-DD') ORDER BY p.CREATION_DATE DESC;

2. Get Purchase Order Line Details

SELECT
l.PO_LINE_ID, l.PO_HEADER_ID, l.LINE_ID, l.ITEM_ID, i.ITEM_NAME, l.QUANTITY, l.UNIT_PRICE FROM PO_LINES_ALL l JOIN INV_MTL_SYSTEM_ITEMS_B i ON l.ITEM_ID = i.ITEM_ID WHERE l.PO_HEADER_ID = :PO_HEADER_ID ORDER BY l.LINE_ID;

3. Retrieve Purchase Order Distributions

SELECT
d.PO_DISTRIBUTION_ID, d.PO_LINE_ID, d.ACCOUNTING_DATE, d.DISTRIBUTION_AMOUNT, l.ITEM_ID FROM PO_DISTRIBUTIONS_ALL d JOIN PO_LINES_ALL l ON d.PO_LINE_ID = l.PO_LINE_ID WHERE d.PO_HEADER_ID = :PO_HEADER_ID ORDER BY d.ACCOUNTING_DATE;

4. Get Supplier Information

SELECT
s.SUPPLIER_ID, s.SUPPLIER_NAME, s.SUPPLIER_TYPE, s.STATUS, s.ADDRESS FROM PO_SUPPLIERS s WHERE s.STATUS = 'Active' ORDER BY s.SUPPLIER_NAME;

5. Retrieve Purchase Order Receipts

SELECT
r.RECEIPT_ID, r.PO_HEADER_ID, p.PO_NUMBER, r.RECEIPT_DATE, r.QUANTITY_RECEIVED, l.ITEM_ID FROM PO_RECEIPTS r JOIN PO_HEADERS_ALL p ON r.PO_HEADER_ID = p.PO_HEADER_ID JOIN PO_LINES_ALL l ON r.PO_HEADER_ID = l.PO_HEADER_ID WHERE r.RECEIPT_DATE BETWEEN TO_DATE('2024-01-01', 'YYYY-MM-DD') AND TO_DATE('2024-12-31', 'YYYY-MM-DD') ORDER BY r.RECEIPT_DATE DESC;

6. List Procurement Agreements and Lines

SELECT
a.AGREEMENT_ID, a.AGREEMENT_NUMBER, a.START_DATE, a.END_DATE, s.SUPPLIER_NAME FROM PO_AGREEMENTS a JOIN PO_SUPPLIERS s ON a.SUPPLIER_ID = s.SUPPLIER_ID WHERE a.START_DATE BETWEEN TO_DATE('2024-01-01', 'YYYY-MM-DD') AND TO_DATE('2024-12-31', 'YYYY-MM-DD') ORDER BY a.START_DATE; SELECT al.AGREEMENT_LINE_ID, al.ITEM_ID, i.ITEM_NAME, al.QUANTITY, al.PRICE FROM PO_AGREEMENT_LINES al JOIN INV_MTL_SYSTEM_ITEMS_B i ON al.ITEM_ID = i.ITEM_ID WHERE al.AGREEMENT_ID = :AGREEMENT_ID ORDER BY al.ITEM_ID;

Notes

  • Refer to the Oracle documentations for any changes to the table names and column names. 
  • For large datasets, consider optimizing queries with appropriate indexing and filtering to enhance performance.

These tables and queries should help you effectively manage and analyze procurement data within Oracle Fusion Applications and can be leveraged for building custom requirements.