QueryTrainingGuide 2
QueryTrainingGuide 2
June 2013
Training Guide
REP200
Table of Contents
REP200 USING QUERY MANAGER TO CREATE AD HOC QUERIES ........................................... 1
COURSE AUDIENCES AND PREREQUISITES ....................ERROR! BOOKMARK NOT DEFINED.
LESSON 1: BASIC QUERY DEVELOPMENT – PLANNING INFORMATION ................................ 3
LESSON 2: DEVELOPING AND REVISING QUERIES ON THE WEB ............................................. 5
2.1 INITIAL NAVIGATION – EXISTING QUERY ............................................................................................. 6
2.2 DEFINING A NEW QUERY ...................................................................................................................... 7
2.3 JOINING RECORDS................................................................................................................................. 8
2.5 PROPERTIES ........................................................................................................................................ 12
2.6 EXPRESSIONS ...................................................................................................................................... 13
2.7 PROMPTS............................................................................................................................................. 15
2.8 FIELDS ................................................................................................................................................ 16
2.8.1 Column Order ............................................................................................................................ 17
2.8.2 Row Sort Order .......................................................................................................................... 18
2.8.3 Field Properties ......................................................................................................................... 19
2.9 CRITERIA ............................................................................................................................................ 19
2.9.1 Grouping Criteria ...................................................................................................................... 20
2.9.2 Adding Criteria .......................................................................................................................... 21
2.9.3 Having Criteria .......................................................................................................................... 22
2.10 VIEW SQL TAB ................................................................................................................................. 24
2.11 RUNNING THE QUERY ....................................................................................................................... 24
LESSON 3: RUNNING QUERIES ON THE WEB ................................................................................. 25
3.1 RUN TO HTML ................................................................................................................................... 25
3.2 RUN TO EXCEL.................................................................................................................................... 27
3.3 SCHEDULING A QUERY ....................................................................................................................... 29
3.4 ADD TO FAVORITES ............................................................................................................................ 34
Training Guide
REP200
Course Outline
The following course sections and lessons provide information and procedures on creating ad hoc
queries using the Query Manager tool in GEARS:
Page 1
Training Guide
REP200
GEARS Role(s)
This course is intended for Judiciary employees with the following GEARS role(s):
Prerequisites
The recommended prerequisites for this course are:
Page 2
Training Guide
REP200
Before beginning to create your query inside the application, it is best to plan the basics of what
the query should produce. Use the following as a general guideline for planning a query. This
list contains both basic and advanced query concepts.
In order to identify what fields to incorporate into the query, you will need to know what tables
are used. The following charts provide a summary of key set up and transactional tables in the
System. This is not a complete list but it does include many of the common records used.
Set Up tables:
Applications Table Description
AP, AR BANK_ACCT_TBL Bank accounts
AP, AR BANK_CD_TBL Bank definitions
PO BUYER_TBL Buyer list
BI, AR CUSTOMER Customer list
BI, AR CUST_ADDRESS Customer address list
AP, PO MASTER_ITEM_TBL Inventory item list
AP, PO VENDOR Vendor list
GL CLASS_CF_TBL Chartfield list (Phase)
GL DEPT_TBL Chartfield list (Departments)
GL GL_ACCOUNT_TBL Chartfield list (Accounts)
GL FUND_TBL Chartfield list (Funds)
GL OPER_UNIT_TBL Chartfield list (Agencies)
GL PRODUCT_TBL Chartfield list (Sub-project)
GL PROGRAM_TBL Chartfield list (Bank codes)
GL PROJECT Chartfield list (Projects)
GL CAL_DETP_TBL Fiscal calendar set up
GL PS_TREENODE Tree node definitions – reporting
GL PS_TREELEAF Tree leaf definitions – reporting
GL TREE_NODE_TBL Tree node descriptions – reporting
Financials PERSONAL_DATA Employee list
GL NVS_REPORT NVision report request list – reporting
GL NVS_SCOPE NVision scope definition - reporting
GL NVS_SCOPE_FIELD NVision scope definition - reporting
GL NVS_SCOPE_VALUE NVision scope definition - reporting
Page 3
Training Guide
REP200
Transaction tables:
Applications Table Description
Billing BI_HDR Invoice headers
Billing BI_LINE Invoice line detail
AR ITEM Receivables
AR ITEM_DST Receivables – GL interface
GL JRNL_HEADER Journal headers – actuals
GL JRNL_LN Journal line detail- actuals
GL LEDGER Posted actual data
GL LEDGER_KK Posted budget and encumbrances
GL KK_BUDGET_HDR Budget journal headers
GL KK_BUDGET_LN Budget journal lines
AR PAYMENT Payments received
AP PAYMENT_TBL Payments made (checks processed)
Purchasing PO_HDR PO headers
Purchasing PO_LINE PO line detail
Purchasing PO_LINE_DISTRIB PO accounting distribution
Purchasing RECV_HDR Receiving information
Purchasing REQ_HDR Requisition headers
Purchasing REQ_LINE Requisition line detail
Purchasing REQ_LINE_DISTRIB Requisition accounting distribution
Purchasing REQ_LINE_SHP Requisition delivery information
AP VCHR_ACCTG_LINE Posted AP transactions-GL interface
AP VOUCHER Voucher table
AP VOURCHER_LINE Voucher line detail
AP VCHR_PPAY_XREF Voucher-Payment cross reference
Page 4
Training Guide
REP200
Page 5
Training Guide
REP200
Page 6
Training Guide
REP200
Click on the Add Record link of the record you need. For this example you will select
MASTER_ITEM_TBL – Item Master Header Table.
This will automatically place you into the Query tab. Use this page to select the fields
you want to display in the query from this first record.
Page 7
Training Guide
REP200
Page 8
Training Guide
REP200
Select either the Standard or Left Outer Join. Note: Typically the standard join is
correct. Left Outer Join should only be used with assistance from an experienced
technical resource.
Click on the blue link of Record you are joining to. In the example below, we will select
ASSET_ITEM_ATTR - Asset Item Attributes.
Page 9
Training Guide
REP200
You can accept the join conditions or uncheck certain fields to not use the Auto Join
Criteria. It is recommended that you use the Auto Join Criteria. Click the Add Criteria
button.
To view the fields of the other record, click the Plus button for that record.
You can select fields from the newly joined record to display in your query.
Page 10
Training Guide
REP200
2.4 Preferences
We will explore two of the links at the bottom of the Query pages: Preferences and Properties.
Enable Auto Join ensures that Query will determine the join conditions for you as shown above.
There are times when it won’t be able to identify joins. You will have to define them in those
circumstances. Clicking Auto Preview will initiate a re-run of the query each time you wish to
preview the query.
Page 11
Training Guide
REP200
2.5 Properties
Properties provide general, high-level definitions for the query.
Query: The query name
Description: Optional – Provide a brief description
Folder: You can organize queries into categories through folders. Here is where you
enter a folder name for the query. This is useful if there are hundreds of queries and you
want only specific queries such as those relating to “General Ledger”.
Query Type: All ad hoc queries you create will be “User” type.
Owner: Public or Private. Private means only available on your User ID.
Distinct: Some queries will return duplicate rows because the query will find multiple
rows of the same data that satisfy the query criteria. Checking this box eliminates your
duplicate rows.
Query Definition: Optional long description of your query.
Note that the last person to update a query and the time of the update displays in
properties.
Click OK.
Page 12
Training Guide
REP200
2.6 Expressions
Expressions are calculations that PeopleSoft Query performs as part of a query. Use them when
you must calculate a value that PeopleSoft Query does not provide by default (for example, to
add the values from two fields together or to multiply a field value by a constant). An expression
can be treated just as if it were a field in the query: select it for output, change its column heading,
or choose it as an “order by” column.
Page 13
Training Guide
REP200
If you select Character, enter the maximum length of the expression result in the Length
field. If you select Number or Signed Number, enter the total number of digits in the
Length field and the number of digits after the decimal point in the Decimal field.
3. If you are entering an aggregate value, such as SUM, AVG, or COUNT, select the
Aggregate Expression check box.
4. In the Expression Text field, enter the expression.
Query Manager inserts the expression into the SQL for you. You can include Oracle hints
in PeopleSoft Query expressions using the following rules:
Expression containing a hint must begin with /*+
Expression can contain only one hint.
For example, only one set of /*+ */ is allowed.
Expression must contain complete hint.
For example, it can't have only /*+ or */. Both must be in the same expression.
5. Click Add Prompt to add prompt properties for this expression; click Add Field to add
another field to this expression.
Page 14
Training Guide
REP200
2.7 Prompts
Adding a prompt enables you to further refine a query when you run it. For example, suppose you
wanted to change a query so that you could prompt the user to enter the month to list posted
ledger data. Prior to adding the prompt, the query always retrieved rows for all months in the
ledger based on a defined constant value. Adding a prompt to the query enables the user to enter
any month, then the query can return only the fiscal period that needs to be analyzed.
When you run a query with a prompt, a dialog box appears for you to specify the required value.
Enter the value into the text box. The query uses the value that you enter as the comparison value.
You can define single prompts in the Criteria section. Prompts for ranges should be defined here
first.
Page 15
Training Guide
REP200
2.8 Fields
The Fields tab provides a display of the fields that have been defined to display in the query.
From this page, you can:
Delete fields
Change the column display order
Change the row sort order
Change the display heading
Apply aggregate functions.
Page 16
Training Guide
REP200
Click the Column Order button to initiate changes to the column display order.
Enter the number sequence for your column display as shown below.
Page 17
Training Guide
REP200
The Sort order defines how rows will display in the output. You can sort on one or more fields.
The sort order dictates which field is the primary sort, secondary sort, etc.
If you want to sort a field in reverse (Z to A or 999 to 0 for example), change the “Direction”
from Ascending to Descending. (Note how Fund Code will sort in reverse).
Page 18
Training Guide
REP200
2.9 Criteria
From the Criteria Page, you can
Display the criteria
Add Criteria
Group Criteria
Reorder the Criteria
Edit existing Criteria
Page 19
Training Guide
REP200
Grouping criteria means putting two or more criteria within parenthesis ( ). This is necessary if
you need to define “AND” and “OR” logic within the Criteria.
Page 20
Training Guide
REP200
Expression 2 must reference a field, expression, prompt, constant value or sub query.
Page 21
Training Guide
REP200
As we are going to select Condition Type - equal to for this exercise, we will choose a
Constant from the list of values under Expression 2.
Page 22
Training Guide
REP200
When you select Field, the eligible fields appear as blue links (note PRICE_LIST).
We want only those items where the list price is greater than $5.00.
Page 23
Training Guide
REP200
You can see the programming statements (SQL) produced from the other tabs. This can be a
useful tool in debugging queries with errors and problems.
Page 24
Training Guide
REP200
Query Viewer is the recommended way to use the queries that have been created in Query
Manager.
You can also select a specific “folder” of queries such as “General Ledger”.
Page 25
Training Guide
REP200
Each output row is numbers and the total number of rows displays in the upper-right.
Optional download to Excel format.
Optional download to a text file.
You cannot edit data in the HTML view. It is purely “read only”.
Page 26
Training Guide
REP200
Display is Web Excel. You can reformat column size and perform all of the Excel
functions that exist in Windows Excel. If the toolbars are not displaying (as they are in
the above example), then navigate: View > Toolbars to display the Excel functional
buttons.
The number of rows displays in cell B-1 in all Web-Excel outputs.
This web output can optionally be saved to a directory on the C: drive or network such as
My Documents. Once saved, it is a regular (.xls) Excel spreadsheet.
Page 27
Training Guide
REP200
To save the web Excel output to a permanent Excel file, navigate: File > Save As
Page 28
Training Guide
REP200
Scheduling queries facilitates running a large query or several queries at a planned future time
and date. That plan could be a “one time” event or a schedule to repeat running the query on a
daily or other timed basis. Note: The Database Administrator should be contacted before
scheduling queries in order to avoid issues with scheduled database maintenance.
The Schedule Query page will re-appear with a Process Instance number when the query has
been properly scheduled. You can monitor the process through the Process Monitor.
Page 29
Training Guide
REP200
Click the blue Process Monitor link to access the Process Monitor. This shows the
status of all your processing requests, including queries.
Page 30
Training Guide
REP200
Queued
Initiated
Processing
Success
Success means the process completed. If there is a problem you will receive an Error Status.
Click the yellow Refresh button to obtain a more recent status from the Process Scheduler. The
Success status shown below means the query is available for viewing.
Page 31
Training Guide
REP200
The Process Details page appears. This page provides access to technical information about the
process that is particularly useful if there is an error in the process.
Click the blue output file link to display the query result.
Page 32
Training Guide
REP200
Page 33
Training Guide
REP200
Favorite queries make it easier to find those queries that you may need to run on a regular basis.
Query Viewer will keep a list of queries identified as “favorites” on the main viewer page,
eliminating the need to search each time the query is needed.
In this example, ASSET_ITEMS will appear in the user’s “My Favorite Queries” list.
Page 34