Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications...

24
Introduction to PeopleSoft Query The University of British Columbia December 6, 1999

Transcript of Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications...

Page 1: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Introductionto

PeopleSoftQuery

The University of British Columbia

December 6, 1999

Page 2: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction
Page 3: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Table of Contents

University of British Columbia 10/16/99 Page i

Table of ContentsTABLE OF CONTENTS........................................................................................................................................... I

CHAPTER 1......................................................................................................................................................... 1

INTRODUCTION TO PEOPLESOFT QUERY.............................................................................................................. 1Understanding Query.................................................................................................................................... 1Types of Queries ........................................................................................................................................... 1

CHAPTER 2......................................................................................................................................................... 2

USING QUERY .................................................................................................................................................... 2The Query Window........................................................................................................................................ 2The Component View .................................................................................................................................... 3The Designer View........................................................................................................................................ 5

CHAPTER 3......................................................................................................................................................... 6

CREATING SIMPLE QUERIES................................................................................................................................ 6Selecting Record Components ....................................................................................................................... 6Viewing Selected REcords and Fields ............................................................................................................ 7Selecting Field Components .......................................................................................................................... 7

SPECIFYING SELECTION CRITERIA....................................................................................................................... 9

CHAPTER 4....................................................................................................................................................... 13

SET PREFERENCES ............................................................................................................................................ 13Check or Change View Preferences............................................................................................................. 13Default View Preferences ............................................................................................................................ 13General View Preferences ........................................................................................................................... 14Component View Preferences...................................................................................................................... 14Designer View Preferences ......................................................................................................................... 14

CHAPTER 5....................................................................................................................................................... 16

FORMATTING QUERY OUTPUT .......................................................................................................................... 16Formatting Options..................................................................................................................................... 16Translate Table Values................................................................................................................................ 18

CHAPTER 6....................................................................................................................................................... 19

RUNNING QUERIES ........................................................................................................................................... 19Running Queries ......................................................................................................................................... 19

CHAPTER 7....................................................................................................................................................... 20

QUERY MAINTENANCE ..................................................................................................................................... 20Saving Queries............................................................................................................................................ 20Printing Queries ......................................................................................................................................... 20Deleting Queries......................................................................................................................................... 20

Page 4: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction
Page 5: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Introduction

University of British Columbia 10/16/99 Page 1

CHAPTER 1

Introduction to PeopleSoft Query

Understanding Query

The main reason you store your business data in a database is so you can manipulate it toanswer questions and solve business problems. Getting just the information you need canoften be a difficult and time-consuming process.

With PeopleSoft Query you can extract the precise data you require. The queries can beas simple or as complex as necessary and they can be one-time queries, or queries youwill use repeatedly.

Types of Queries

You create queries to extract the data you need from the database. Since there are manyreasons you might need data, there are many ways you can use queries:

• Display data in a grid control (on the Results tab). You can run queries within Queryitself, displaying the results set in a grid control for review. This option is useful asyou define and refine your queries.

• Provide input into a spreadsheet or Crystal Report. Query can seamlessly pass datato Microsoft Excel or Crystal Reports Pro. From there, you can use the features ofthese products to create polished reports.

• Search for records. Many of the search dialog boxes in PeopleSoft applicationsallow you to open Query and create a search query based on sophisticated searchcriteria.

• Create views. Queries can be used in the Application Designer to generate views.Using queries instead of SQL has two big advantages: you can use the PeopleSoftQuery to generate the SQL text for your view, and the SQL that is generated isdatabase independent.

• Check the database for conditions that trigger workflow events. Using PeopleSoftWorkflow, you can specify that certain conditions – for example; the presence ofoverdue receivables – cause the system to send an e-mail to someone or put an entryin someone’s worklist. You write queries to detect these conditions, then youschedule database agents to run them periodically.

Page 6: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Using Query PeopleSoft Query

Page 2 10/16/99 University of British Columbia

CHAPTER 2

Using Query

The Query Window

The Query window is split into the Component View (on the left) and the Designer View(on the right).

Component View Designer View

• Adjust the relative size of either view by dragging the divider bar.

• View text in components that is ‘cut off’ by the divider bar by placing the mousepointer over the item. No clicking is necessary.

Page 7: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Using Query

University of British Columbia 10/16/99 Page 3

The Component View

The component view provides access to tables in the database. The component view has twotabs: Database and Query. Pay attention to which tab is active as you work; they look verysimilar.

THE DATABASE TAB

Gives you a list of available tables. You can view these tables as either a tree of accessgroups (see figure on page 2) or an alphabetical tree of tables to which your operator IDhas access.

COMPONENT VIEW ICONS

Database name (displayed in the database component view only)

Query name and public/private status (displayed in the querycomponent view only)

Table

Table hierarchy or related record hierarchy

Page 8: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Using Query PeopleSoft Query

Page 4 10/16/99 University of British Columbia

Related table

Field

Key field

Field having a related record

Key field having a related record

Expressions (the part of the query that contains individual expressioncomponents)

An expression component (a single expression that has been defined aspart of the query)

Prompts

THE QUERY TAB

Displays all the components used in the current query. Components consist of tables,fields, prompts, expressions, and so on.

Component View Designer View

Page 9: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Using Query

University of British Columbia 10/16/99 Page 5

The Designer View

The designer view is where you see the fields, criteria, and other details associated with thecurrent query. The designer view has four tabs.

Fields – displays the fields you select for the query.

Criteria – allows you to set limits and conditions for the query.

SQL – shows the SQL code generated from the fields and criteria.

Results – displays the query results.

Page 10: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Creating Simple Queries PeopleSoft Query

Page 6 10/16/99 University of British Columbia

CHAPTER 3

Creating Simple Queries

Selecting Record Components

The first step in creating a query is to select the database tables that hold the data you want. InQuery, the tables are referred to as record components, since they are one type of component ofyour query. For clarity, we call the components tables, which is what they in fact are.

All operations on a table are performed from the Edit menu. First, select a table from the tree;then select an operation to be applied to that table from the Edit menu.

There are several ways to select the table you want:

• Click the Database tab in the component view.

• Double click the desired table name (not the + sign).

OR

• Drag the table from the Component View (on the left) to the Designer View (on theright).

OR

• Right-click on the table name and select Add from the pop-up menu.OR

• Highlight the table name and select Edit menu, Add.

If this is not the first table in the query, the menu option will read New Join to indicate ajoin operation. (Note: To use the Edit menu, you must first highlight a component in theComponent View).

Once you have selected a record component, Query automatically switches thecomponent view from the Database tab to the Query tab to show the new recordcomponent that was added to the query. The designer view may or may not show fields,depending on how you have specified your view preferences.

If you have selected the record component for an effective-dated table, Querydisplays a dialog box asking you how you want to handle the effective dates inthe query.

Page 11: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Creating Simple Queries

University of British Columbia 10/16/99 Page 7

Viewing Selected REcords and Fields

At the top of the query component tree is the table you selected, along with a letter,followed by the fields comprising the record. Query uses the letter as an ‘alias’ for thetable name. This prefix is a shorthand way of indicating which table contains this field.The first table you select will appear as record A, the second as record B, and so on.

Selecting Field Components

Once you have selected the tables that hold the data you want, select specific fields from thetables.

• Click the Query tab in the component view.

• Double click the field you want to select.OR

• Drag and drop the field into Designer View.

Notice what happens in the Designer View. With the Fields tab active, a number appearsin the first column (Col), indicating the order of the fields in the query results.

Query adds columns in the order to you select the fields – the first field you select willappear as column one, the second as column two, and so on. You can select fields in anyorder; you don’t need to use the order from the record component. Or you can change theorder of the fields later.

CHANGE ORDER OF FIELDS

• Right-click on the row that contains the field you want to move.

Page 12: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Creating Simple Queries PeopleSoft Query

Page 8 10/16/99 University of British Columbia

• Select Column Number from the pop-up menu. Enter new column number in thedialog box.

• Click OK. Query renumbers the remaining fields to reflect the new column order.

REMOVE A FIELD

• Double click the field in the Col column.

OR

• Right click the field and click Select from pop-up menu. Query removes the fieldfrom the query and renumbers the remaining fields.

The Designer View can show the fields from one or all of the record components youhave selected. Again, this depends on your view preferences. However, you can alwaystell which table a field comes from by looking at its prefix (A, B etc.).

Page 13: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Creating Simple Queries

University of British Columbia 10/16/99 Page 9

Specifying Selection CriteriaBecause PeopleSoft database stores data in tables, you can identify every individual piece of databy saying what column and row it is in. When you create a query, you pick the data you want byspecifying which columns and rows you want the system to retrieve.

You select which rows of data you want by adding selection criteria to the query. (For example,suppose you needed the names of all Bookstore customers who are not UBC employees. You startby creating a query that retrieves the Name and Company fields from the Customer table. Then youadd a selection criterion that tells Query to scan for rows where the Company name is not UBC.)

In most cases, you don’t want every row of data from the table specified in your query, just therows that meet certain conditions. To specify the conditions you apply criteria to the field(s).

SET SELECTION CRITERIA

• Click the Criteria tab in the designer view. This panel displays one row for eachquery criterion.

• Click the Query tab at the bottom of the component view, and then scroll to the fieldyou want. Select the field.

• Drag the record field on to the Criteria tab in the designer view.

Note: If you double click a field it will be added to the Fields tab not the Criteria tab.

CRITERIA TAB

The Criteria Tab has four columns:

• Logical: Any rows after the first row must include either “AND” or “OR” logicalvalue. These are in addition to other criteria. The default is AND.

• Expression: In most cases, the left-hand expression will be a field whose value youwant to base the selection criterion on.

• Operator: See page 10.

• Expression: See page 11.

Page 14: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Creating Simple Queries PeopleSoft Query

Page 10 10/16/99 University of British Columbia

• In the Operator column, click the down arrow and select an expression from thedrop-down box. (The ‘equal to’ operator is the default.)

SELECTING OPERATORS

Operator What it does

Equal to The value in the selected record field exactly matches thecomparison value.

Greater than The value in the record field is greater than the comparisonvalue.

Less than The value in the record field is less than the comparison value.

In list The value in the selected record field matches one of thecomparison values in a list. You select the value type by right-clicking in the second Expression column.

Between The value falls between two comparison values. The range isinclusive.

Exists This operator is different from the others in that it does notcompare a record field to the comparison value. The comparisonvalue is a subquery. This will be covered in the Advanced Queryworkshop.

Like The value matches a specified string pattern. The comparisonvalue may be a string that contains wildcard characters.*

Is null The selected record field does not have a value in it. You do notspecify a comparison value for this operator.

In tree The value appears as a node in a tree created with the TreeManager.

*Wildcards – Query recognizes these wildcard characters:% matches any string of characters. E.g. ‘C%’ matches anything starting with C, including C alone._ matches any single character. E.g. ‘_ones’ matches any five-character string ending with ‘ones’ such as Jones, cones.

Note: To use % as a literal character enclose it with \ as:‘percent\%\’

Note: It is always better to use the ‘not’ version of an operator than to use NOToperator in the Logical column.

Note: The Criteria field does not have to be one of the fields you select for thequery output.

Page 15: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Creating Simple Queries

University of British Columbia 10/16/99 Page 11

ENTERING COMPARISON VALUES

There are two Expression columns, one to the left of the Operator column, and one tothe right. You normally do not have to change the left-hand Expression column – itcontains the field name. If the right-hand Expression column is not visible, use thehorizontal scroll bar at the bottom of the designer view to scroll to it, or resize thewindow so both left and right hand expression columns are visible, or resize the columns.

• Right-click in the right-hand Expression column.

What you select depends on what kind of value you are entering.

Value Type What it does

Field A value in another field, usually a field in another table.

Expression An expression you enter. Query evaluates the expression oncefor each row it tests.

Constant A single fixed value.

Subquery Data returned by a subquery. Advanced Query workshop.

Prompt You will enter a value in a dialog box.

In List This value type is available only when the selected operator is‘in list’ or ‘not in list’.

Current Date The current date on the database server.

Tree Option A selected set of tree nodes. This value is available only whenthe selected operator is ‘in tree’ or ‘not in tree’.

Effective Seq Used on some effective-dated records. Advanced option

• Select operator from the pop-up menu, and type your value in the dialog box thatappears.

Page 16: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Creating Simple Queries PeopleSoft Query

Page 12 10/16/99 University of British Columbia

Continue setting criteria for any other field. Ensure that your Operator and Expressionvalues are what you want.

Note that the Logical column defaults to a value of “AND” when you have more thanone criteria expression. Take care when you change this value to ensure that the resultsreflect what you want.

Note that some of the Operators may interfere with the Logical expression when it isother than “AND”.

Page 17: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Set Preferences

University of British Columbia 10/16/99 Page 13

CHAPTER 4

Set Preferences

What you see in the component view and the designer view often depends on what Preferenceshave been defined for your Query.

Check or Change Preferences• Select View menu, Preferences. The Preferences dialog box includes three tabs

labeled General, Component View, and Designer View.

Default View Preferences

View Preferences Tab Default Values

General • Show User Queries

Component View • Show Access Groups

Designer View • Show Fields in Select List• Sort Fields by Col Order• Don’t run query when Result tab is clicked• Don’t show row headers in Result tab

Whenever you change view preferences, the new settings are saved in Windows and are retainedfrom one Query session to another.

Page 18: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Set Preferences PeopleSoft Query

Page 14 10/16/99 University of British Columbia

General View Preferences

The General view preferences enable you to select a Name Style and to specify File ListOptions.

• The Name Style determines whether field components appear with both their fieldname and description or with the description only.

• The three File List Options determine which type of query is displayed in the OpenQuery dialog box.

Component View Preferences

The Component View preferences tab allows you to turn the Show Access Groups option on oroff. In the Database Component view, you will see either access groups or an alphabetical list oftables (records) to which you have access.

Designer View Preferences

The Designer View tab controls which fields you see when building your query and in what orderthey appear. You can combine the Designer View options to display the fields in the way thatbest suits your query needs.

RESULT TAB

These options determine whether or not to Show Row Headings on the Result tab.

You can use the Run query on tab select option to automatically run the current queryanytime the user clicks the Result tab.

SHOW FIELD

These buttons specify what fields appear in the designer view.

• In Record displays all the fields in the table that is highlighted in the componentview. Even if you have selected more than one table in your query, you only see thefields in the highlighted table.

• In Select List displays only those fields selected for output data in the entire query.

• In Order By displays all the fields in the entire query that control the order of theoutput rows.

• With Criteria displays only those fields in the entire query that have selectioncriteria associated with them, no matter which record is selected in the componentview. If no fields have criteria, then no fields are shown.

• All shows all the fields which the query will use for its result, including those whichmay not have been selected, but which contain criteria.

Page 19: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Set Preferences

University of British Columbia 10/16/99 Page 15

SORT FIELDS BY

This determines the order of the fields in the designer view. You can use any Sort FieldsBy option with any Show Fields option.

• Record Field displays fields in the order they appear in the record component(s). Ifyour query uses fields from more than one record, the fields from record ‘A’ aresorted before those of record ‘B’ and so on.

• Col Order displays the fields in the query in the order they will be displayed in youroutput. This is the default Sort Field Option. When Col Order view option is active,you can change the column order by dragging and dropping the field rows.

• Field Name displays the fields in alphabetical order, no matter where the field camefrom.

• Order By Number places at the top of the list those fields selected to order theoutput rows, followed by the rest of the fields in record order. The Ord columnshows which fields you have selected for ordering.

Page 20: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Format Query Output PeopleSoft Query

Page 16 10/16/99 University of British Columbia

CHAPTER 5

Formatting Query Output

Once you have selected the fields to include in the query, you are ready to format the query output.

Formatting Options

You can make some decisions about the format of the Query output.

To display or change currently assigned formatting:

• Right-click anywhere on the field in the Designer View, Fields tab.

• Select one of the options from the pop-up menu.

• The most common formatting options you use are Column Number, Heading andOrder By. Clicking any of these options opens the Field Properties dialog box.

FIELD PROPERTIES

Page 21: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Format Query Output

University of British Columbia 10/16/99 Page 17

COLUMN NUMBER

This is where you can re-order the columns.

HEADING

This is where you select or change headings for your columns. The heading options are:

Option Effect

None • The column does not have a heading

Text • The column heading is the text you enter in the text box.

RFT Short • The column heading is the short name of the field fromthe record definition

RFT Long • The column heading is the long name of the field fromthe record definition

If you start typing text into the text box, Query automatically selects the Text option.

ORDER BY

You can select one or more fields to sort your output.

• Double click in the Ord column. Query puts a number in the column. If this field isthe first you selected, a 1 appears in the Ord column.

• The second column you click will be numbered 2 and so on. You can sort by asmany fields as you like.

Query will sort the rows by the first sort field, then use the second field to sort rows withthe same value in the first field.

CHANGING THE SORT ORDER

• Right click on the field’s row

• Select Order By from the pop-up menu. The Field Properties dialog box appears.

• Enter an Order By Number in the dialog box

• Select Descending if you like. (The default is Ascending.)

• Click OK

Page 22: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Format Query Output PeopleSoft Query

Page 18 10/16/99 University of British Columbia

Translate Table Values

Some fields may contain a short code, for which the Translate Table provides a correspondingset of values. If you use such a field in your query, a letter appears in the Xlt column for thatfield. By default, the letter is N (for None), meaning that Query will not replace the codes withthe corresponding translate values. The other two values are L for Long and S for Short.

If you want to display the translated value rather than the code, for example Activeinstead of A, you must set the translate value options.

SET TRANSLATE VALUE OPTIONS

• Right click anywhere on the field in the Designer View

• Select Translate from the Pop-up menu. The Field Properties dialog box appears.

• Specify which Translate Value you want.

• Select Effective Date. For most tables, Query defaults to the Current Date.

• Click OK. In the Designer View, an N, L, or S appears in the Xlt column to indicatewhich translate values will be used, if any.

Page 23: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

PeopleSoft Query Query Maintenance

University of British Columbia 10/16/99 Page 19

CHAPTER 6

Running Queries

Running Queries

After designing a query, you will want to run it to see the results. Query provides several outputoptions, each of which can be extremely useful depending on your needs.

OUTPUT OPTIONS

Output Option To RunSelect

Description

Grid control File,Run(CurrentQuery)

OR click

To send the output to the grid control on theResults tab of the Designer View.

This option is useful as you design and refinequeries to get just the results you want. Whenyour query is perfect, you can use one of theother output options.

Excel File, Run toExcel

OR click

To send the output to MS Excel (using QueryLink discussed below).

Crystal Reports File, Run toCrystal

OR click

To send the output to Crystal Reports Pro, areport formatter, where you can use predefinedformats or create new ones to print the resultsof your query.

QUERY LINK

QueryLink allows you to send the results of a query directly to an Excel spreadsheet,bypassing the need for a PeopleSoft nVision layout. Any query results sent to Excelthrough QueryLink are based on the QUERY.XLT Excel template. Therefore, if youwant to make any permanent changes to spreadsheets derived through QueryLink, makethe changes to QUERY.XLT.

Page 24: Introduction to Query · PDF fileMany of the search dialog boxes in PeopleSoft applications allow you to open Query and create a search query based on sophisticated ... Introduction

Running Queries PeopleSoft Query

Page 20 10/16/99 University of British Columbia

CHAPTER 7

Query Maintenance

Saving Queries

Once you have designed a query, you must save it if you want to use it again. You save Queriesas Public or Private. Public Queries are available to other users. If you save a Query as Private,you give it an Operator ID, which restricts use and update of the Query to you alone.

To save a query:

• Select File menu, Save (or Save As).

• Give an easily recognizable name and description to your query. Maximum size is 30characters.

• Click OK.

Printing Queries

It is a good idea to document your queries. When you print a query object, you print thedefinition of the query, not the results. To print a query:

• Select File menu, Print (Current Query Object).

Deleting Queries

To delete a query

• Select File menu, Delete.

• In the Delete Query dialog box click the down arrow to view the Query list andselect the Query you want to delete.

• Click OK.