Using Expressions in PS Query

From TekiWiki
Jump to: navigation, search

Expressions in PeopleSoft Query are based on the functions and capabilities of the underlying database platform. For instance, if you are using the Oracle database, you can make use of Oracle SQL functions in your Query, if using SQL Server - you can use SQL Server's SQL functions and so on.

Although there are SQL standards, many of the SQL functions are not part of those standards. For this reason, the expressions listed below are Oracle SQL functions (hope to include SQL Server and other plaforms later).

Oracle SQL Functions in PeopleSoft Query

Function: || (Concatenate)

Usage: 'Putting ' || A.COLUMN || ' and strings together'

This concatenates (puts together) column values and fixed character values. This has got to be one of the most useful functions.

Examples

'PS_' || A.RECNAME /* Gives the standard table name from the record name. */


Function: Substr

Usage: substr(A.DESCR,start_position,number_of_characters)

Usage: substr(A.DESCR,start_position)

Usage: substr(A.DESCR,-start_position,number_of_characters)

This extracts a part of a text column.

Examples

Substr(A.DESCR,3) /* The description without the first three characters */

Function: Translate

Usage: translate(A.DESCR,'List1','List2')

Usage: translate(A.DESCR,'X1234567890','X')

Translates characters in the column found in first list with corresponding character in the second list.

Examples

Show the format of NATIONAL_ID - useful in a group by query:

translate(NATIONAL_ID,
'0123456789' ||'abcdefghijklmnopqrstuvwxyz'||'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
,rpad('9',10)||rpad('x',26)                ||rpad('X',26)) /* Format of NATIONAL_ID */

translate(DESCR,'-0123456789','-') /* Removes digits from descriptiont field. */

More About Functions

UsingFunctionsInPeopleSoftQuerySmall.jpg For more information about functions in PeopleSoft Query and some other interesting stuff too, read our eBook:

Using Functions in PeopleSoft Query

Other Reading

PeopleSoft Query