Professional Documents
Culture Documents
Steve Bradley
Atlanta OAUG
October 15, 1999
OASIS
Consulting Group, Inc.
Agenda
• SQL Overview
• Payables Tables
• Table Relationships
• Practical Examples
• T.O.A.D
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
SQL Overview - Select
• Select column_name1, column_name2, …
From table_name
Where criteria
– What are we going to do?
– What columns are we interested in?
• Select is (almost) always safe to use
– It never changes data
– It can tie up computer resources with large tables and
complex (inefficient) queries
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Update
• Update table_name
Set (column_name1, column_name2, …)
= (value1, value2, …)
Where criteria
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Delete
• Delete
From table_name
Where criteria
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
From
• From table_name1, table_name2, ...
– What table(s) are we going to use?
– You can Select data from more than one table in a
query
– You can Update only one table at a time
(from is not used in Update)
– You can Delete from only one table at a time
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Where
• Where criteria
– What is our selection criteria?
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Order by
• Order by column_name1, column_name2, ...
– How do we want it sorted?
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Payables Tables
• Technical Reference Manual - TRM
– GL_CODE_COMBINATIONS
– PO_VENDORS
– PO_VENDOR_SITES_ALL
– AP_BATCHES_ALL
– AP_INVOICES_ALL
– AP_INVOICE_DISTRIBUTIONS
– AP_CHECKS_ALL
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
GL_CODE_COMBINATIONS
• The most used table in Oracle Applications
• Stores all AFF combinations
• Very few tables store actual segment values
• Almost all tables store CCID (code
combination ID) found in this table
• Any query displaying the AFF must Select
from this table
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
PO_VENDORS
• Stores most data keyed into the Supplier
setup form
– Vendor Name
– Vendor Number
– Vendor Type
– Tax info
– Terms
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
PO_VENDOR_SITES_ALL
• Stores most data keyed into the Sites form
– Site Name
– Address lines
– Site Terms
– Site PayGroup
– Org_ID
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
xxxxx_All Tables
• These are Multi-Org tables
• _All means there is a column named
Org_ID in the table
• This is why you cannot see Vendor sites
belonging to another Organization
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
AP_BATCHES_ALL
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
AP_INVOICES_ALL
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
AP_CHECKS_ALL
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Table Relationships
• Oracle is a “Relational Database”
– All data is not stored in one table
– Data is not duplicated in different tables
– You must use table relationships to “join”
tables to see the full picture
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Relationship Example
• Vendor names are not stored in the
AP_INVOICES_ALL table
They are stored in the PO_VENDORS table
• AP_INVOICES_ALL has a column named
vendor_id
• PO_VENDORS also has a column named
vendor_id
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Table Relationships
Vendor_ID
PO_Vendors AP_Invoices_All
Vendor_ID Vendor_ID
Where PO_Vendors.Vendor_id =
AP_Invoices_All.Vendor_id
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Table Relationships
Vendor_ID AP_Invoices_All
PO_Vendors Vendor_ID
Vendor_ID Vendor_Site_ID
Invoice_ID
PO_Vendor_Sites_All
AP_Invoice_Dist_All
Vendor_ID
Invoice_ID
Vendor_Site_ID
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Unused Vendors
• During initial Oracle Payables
implementation typically all vendors in the
old system are copied over to Oracle.
• Many of these vendors are never used in
Oracle.
• How can you get a list of them?
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
--Vendors with no Invoices
select segment1 VENDOR#,
vendor_name NAME,
vendor_site_code SITE_CODE,
end_date_active VEND_INACTIVE,
inactive_date SITE_INACTIVE
from po_vendors vend,
po_vendor_sites_all sites,
ap_invoices_all inv
where vend.vendor_id = sites.vendor_id
and sites.vendor_site_id = inv.vendor_site_id(+)
and inv.vendor_site_id is null;
OASIS
Consulting Group, Inc.
Consulting Group, Inc.
Legal Disclaimer
• Oracle does not provide Application support for
non-interface tables that have been updated
directly using SQL
• Use these SQL scripts at your own risk
• You can give me credit for these scripts but I will
accept no blame for their use
• Do not call me with problems or support
• If you do not understand them - do not use them
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Practical Examples
• Vendor Merge
– Fix Duplicate Invoices resulting from a merge
– Duplicate Vendors Listing
– Vendor Unmerge
• Delete Unused Vendor Sites
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Practical Examples
• Dead Vendors
– Unused Vendors
– Vendors with only activity being
Canceled Invoices
– Vendors with % in name
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
T.O.A.D
• Tool for Oracle Application Developers
• Great tool for writing SQL
• It’s free - download from:
www.toadsoft.com
• Must download new version every 2 months
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
T.O.A.D Features
• Easy editing features - cut and paste, query recall
• Output goes to a grid - does not wrap like Oracle
• You can change the order of the output columns
after running
• Can export data in .CSV format (can then import
into Excel)
• Can save SQL scripts to PC and use later
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com
Questions
Steve Bradley
OASIS Consulting Group
sbradley@sprynet.com
Office 404-352-8387
FAX 503-218-9747
Pager 888-912-2569
OASIS
Consulting Group, Inc.
Steve Bradley sbradley@sprynet.com