Oracle Fusion - SQL Query for Suppliers
|
3 min read
Oracle Fusion - SQL Query for Suppliers
Supplier master extract: supplier number, name, procurement BU, status, type, business relationship and creator. Built for Energix on Oracle Fusion Cloud via the RunSQL.xdo BIP data model. A BU-secured variant below restricts rows to suppliers whose site BU the calling user is entitled to.
Query — base (no security)
SELECT sup.segment1 AS supplier_number,
pty.party_name AS supplier_name,
LISTAGG(DISTINCT bu.name, ', ')
WITHIN GROUP (ORDER BY bu.name) AS supplier_bu, -- procurement BU(s) from the sites
CASE
WHEN sup.enabled_flag = 'N' THEN 'Inactive'
WHEN sup.end_date_active IS NOT NULL
AND sup.end_date_active <= TRUNC(SYSDATE) THEN 'Inactive'
ELSE 'Active'
END AS supplier_status, -- derived; no STATUS column exists
sup.vendor_type_lookup_code AS supplier_type,
sup.business_relationship AS business_relationship,
sup.created_by AS creator_username
FROM poz_suppliers sup,
hz_parties pty,
poz_supplier_sites_all_m sit,
hr_all_organization_units_vl bu
WHERE pty.party_id (+) = sup.party_id
AND sit.vendor_id (+) = sup.vendor_id
AND TRUNC(SYSDATE) BETWEEN sit.effective_start_date (+) AND sit.effective_end_date (+) -- current site row
AND bu.organization_id (+) = sit.prc_bu_id
GROUP BY sup.segment1,
pty.party_name,
sup.enabled_flag,
sup.end_date_active,
sup.vendor_type_lookup_code,
sup.business_relationship,
sup.created_by
ORDER BY sup.segment1;
Query — BU-secured by caller email
Restricts output so a user sees a supplier only if that supplier has a site in a Business Unit the user has data access to. Same email→BU chain used across the row-level security work — see Oracle Assistant V3 - Row-Level Document Security and Orecle Fusion - Query for Data Access.
WITH me AS ( -- resolve caller's verified email -> user_guid (fail-closed)
SELECT pu.user_guid
FROM per_email_addresses pea,
per_users pu
WHERE pea.mastered_in_ldap_flag = 'Y'
AND SYSDATE BETWEEN NVL(pea.date_from, SYSDATE-1) AND NVL(pea.date_to, SYSDATE+1)
AND UPPER(pea.email_address) = UPPER(:p_user_email) -- Make passes the Graph-verified email
AND pu.person_id = pea.person_id
),
my_bus AS ( -- Business Units the caller has data access to
SELECT DISTINCT bu.bu_id
FROM me,
fun_user_role_data_asgnmnts role,
fun_all_business_units_v bu
WHERE role.user_guid = me.user_guid
AND role.org_id = bu.bu_id -- BUSINESS UNIT data-access context
AND NVL(role.active_flag,'Y') = 'Y'
)
SELECT sup.segment1 AS supplier_number,
pty.party_name AS supplier_name,
LISTAGG(DISTINCT bu.name, ', ')
WITHIN GROUP (ORDER BY bu.name) AS supplier_bu,
CASE
WHEN sup.enabled_flag = 'N' THEN 'Inactive'
WHEN sup.end_date_active IS NOT NULL
AND sup.end_date_active <= TRUNC(SYSDATE) THEN 'Inactive'
ELSE 'Active'
END AS supplier_status,
sup.vendor_type_lookup_code AS supplier_type,
sup.business_relationship AS business_relationship,
sup.created_by AS creator_username
FROM poz_suppliers sup,
hz_parties pty,
poz_supplier_sites_all_m sit,
hr_all_organization_units_vl bu,
my_bus
WHERE pty.party_id (+) = sup.party_id
AND sit.vendor_id = sup.vendor_id -- INNER: a visible supplier must have a site
AND TRUNC(SYSDATE) BETWEEN sit.effective_start_date AND sit.effective_end_date
AND bu.organization_id = sit.prc_bu_id
AND sit.prc_bu_id = my_bus.bu_id -- SECURITY GATE: site BU in caller's access
GROUP BY sup.segment1,
pty.party_name,
sup.enabled_flag,
sup.end_date_active,
sup.vendor_type_lookup_code,
sup.business_relationship,
sup.created_by
ORDER BY sup.segment1;
Field & table notes
- Supplier number =
poz_suppliers.segment1. - Name — not on
poz_suppliers; it lives on the party (hz_parties.party_nameviaparty_id). (Theorganization_name_phonetic"Alternate Name" was dropped from the final version.) - Supplier BU — not on the header. It comes from the procurement BU (
prc_bu_id) on the supplier site (poz_supplier_sites_all_m, date-effective — the_Msuffix is what's exposed;poz_supplier_sites_allis not).LISTAGG DISTINCTcollapses multiple site BUs into one row per supplier. - Status — there is no
STATUScolumn onpoz_suppliers; it is derived fromenabled_flag+end_date_activeto match Active/Inactive in the Suppliers work area. - Type =
vendor_type_lookup_code.business_relationship(Spend Authorized / Prospective) is the other "type" people often mean. - Creator =
created_by(raw username). Resolving it to a display name viaper_users/per_person_names_ffailed with ORA-00942 in this data model — those views aren't exposed toRunSQL.xdo. - If
hr_all_organization_units_vlerrors (ORA-00942), swap it forfun_all_business_units_vand joinbu.bu_id (+) = sit.prc_bu_id, selectingbu.bu_name.
Security model (BU-secured variant)
- Email → user_guid:
per_email_addresses(mastered_in_ldap_flag='Y', date-effective) →per_users— the same identity anchor as Oracle Assistant V3 - Row-Level Document Security. Bind the Graph-verified:p_user_email, never chat text (anti-spoof / anti-injection). - User → BU access:
fun_user_role_data_asgnmnts.user_guid = per_users.user_guidwithrole.org_id = fun_all_business_units_v.bu_id(BUSINESS UNIT data-access context, from Orecle Fusion - Query for Data Access). - Gate: the supplier site's
prc_bu_idmust be one of the caller's accessiblebu_ids. The site join becomes inner (a supplier with no accessible site must not leak), andsupplier_buthen shows only the caller's BUs. - Fail-closed: an email that doesn't resolve, or a caller with no BU data access, yields zero rows.
Related
- 2026-07-26N1 - Supplier Master Data — inactive-suppliers procedure this extract supports.
- Orecle Fusion - Query for Data Access · Oracle Assistant V3 - Row-Level Document Security — the email→BU security layer reused here.
- Oracle Fusion - SQL Query for Business Units · Oracle Fusion - SQL Query for Requisitions — sibling reference-data extracts.
- Purchasing · ERP
קישורים (Zettelkasten)
- מושג יסוד: Oracle Fusion - PP2 Procure to pay — מודל ה-P2P שהספקים נשענים עליו.
- תלוי ב: Orecle Fusion - Query for Data Access — מיפוי משתמש→BU דרך
FUN_USER_ROLE_DATA_ASGNMNTS. - מקביל ל: Oracle Fusion - SQL Query for Business Units — שאילתת reference-data אחות.
- קשור ל: Oracle Assistant V3 - Row-Level Document Security — אותה שכבת זיהוי email→person→BU.
- חלק מ: Oracle Fusion SQL MOC