Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Use Instead
BEGIN-REPORT (END-REPORT)
BEGIN-PROGRAM (END-PROGRAM)
DATE-TIME
Datenow function
DECLARE PRINTER
DECLARE-PRINTER
DECLARE PROCEDURE
DECLARE-PROCEDURE
DOLLAR-SYMBOL
ALTER-LOCALE
GRAPHIC FONT
ALTER-PRINTER
MONEY-SYMBOL
ALTER-LOCALE
NO-FORMFEED
DECLARE-LAYOUT
PAGE-SIZE
DECLARE-LAYOUT
PRINTER-DEINIT
DECLARE-PRINTER
PRINTER-INIT
DECLARE-PRINTER
PRINT...CODE
PRINT...CODE-PRINTER
Note: Two older commands, DECLARE PRINTER and DECLARE PROCEDURE, do not
contain hyphens. The new commands, DECLARE-PRINTER and DECLAREPROCEDURE, contain hyphens.
14. How do you execute a procedure?
A. By using "DO" command
In SQR, a procedure is a group of commands that are performed one after the other, like
a procedure (or subroutine) in other programming languages. A DO command invokes a
procedure. PeopleSoft recommends that you break your program logic into procedures
and keep the PROGRAM section small. It should normally consist of a few DO
commands for the main components of your report.
Specifies an SQR procedure to execute for each row selected in the query. Processing
continues until all rows have been retrieved. You can specify arguments to be passed to
the procedure. Arguments can be any variable, column, or literal.
15. How do you print a message in the SQR?
A. Using DISPLAY 'Hello World'
Syntax: DISPLAY {any_lit|_var|_col} [[:$]edit_mask|NUMBER|MONEY|DATE][NOLINE]
Displays the specified column, variable, or literal.
The DISPLAY command can display data to a terminal. The data is displayed to the
current location on the screen. If you want to display more than one field on the same
line, use NOLINE on each display except the last.
The SHOW, command for information about screen control.
The LET, command for information about copying, editing or converting fields.
The EDIT parameter of the PRINT command for a description of the edit masks.
The ALTER-LOCALE command for a description of the arguments NUMBER-EDITMASK, MONEY-EDIT-MASK, and DATE-EDIT-MASK.
Example
! Display a date column using the locale default date edit mask
begin-select
dcol
from tables
end-select
alter-locale date-edit-mask = 'DD-Mon-YYYY'
Update Server Status: Select to allow a user to suspend, restart, or shut down a server if
needed through the Process Monitor. This also allows a user to refresh the Process
Monitor - Server List page with the Refresh button.
Specify the maximum number of attempts that the PeopleSoft Process Scheduler Server
Agent will try reconnecting to the database when the connection is lost. When the
maximum number of attempts is reached and the agent hasn't successfully connected to
the database, the agent shuts down.
18. What is the difference between Show and Display?
A. Displays one or more variables or literals on the screen. In addition, cursor control is
supported for ANSI terminals. Any number of variables and screen positions can be used
in a single command. Each one is processed in sequence. Fixed or relative cursor
positioning can be used only within the boundaries of the terminal screen. Scrolling off
the screen using relative positioning, for example (+1,1), is not supported. Instead, use a
SHOW command without any cursor position when you want to scroll. Also, you cannot
mix SHOW and DISPLAY commands while referencing relative cursor positions.
The SHOW command does not advance to the next line if a cursor location (...), CLEARSCREEN, CLEAR-LINE, or BEEP is used. (A SHOW command without any of these
arguments automatically advances the line.) To add a line advance, add (+1,1) to the
end of the line or use an extra empty SHOW command.
Only ANSI terminals are supported for cursor control, screen blanking, line blanking, and
display characteristics.
The following program segments illustrate the various features of the SHOW command:
!
! Show a string using an edit mask
!
let $ssn = '123456789'
show $ssn edit xxx-xx-xxxx
Produces the following output:
123-45-6789
! Show two values on the same line with editing of the values
!
let #taxes = 123456.78
show 'You owe ' #taxes money ' in back taxes.'
Produces the following output:
You owe $123,456.78 in back taxes.
19. What are the SQC used in the SQR?
A. SQC: You need to include this in the SQR file, which you write at the end of the file.
This sqc will contain the procedure for the Current Date. So that you can, call the
procedure within this sqc in your Sqr program. You can get this SQC in the SQR
directory available in PS Root directory or search for the same in PS directory.
20. What are the minimum things, required in the SQR? Which is the section compulsory
in the SQR?
A. PROGRAM section is the minimum section required and it must be present in the
program, and you may have only one. It is typically placed at or near the top of the
program.
21. Load look up in sqr, where did you use? What is difference between load-lookup and
Array?
A. Loads an internal table with columns from the database. Enables a quick search
using the LOOKUP command. Use the LOAD-LOOKUP command in conjunction with
one or more LOOKUP commands.
LOAD-LOOKUP retrieves two columns from the database, the KEY field and the
RETURN_VALUE field. Rows are ordered by KEY and stored in an array.
LOAD-LOOKUP commands specified in the SETUP section are always loaded and
cannot reference variables for the ROWS, EXTENT, and WHERE arguments.
When you use the LOOKUP command SQR searches the array (with a "binary" search)
to find the RETURN_VALUE corresponding to the KEY referenced in the lookup.
Usually this type of lookup can be done with a database join, but joins take substantially
longer. However, if your report is small and the number of rows to be joined is small, a
lookup table cannot be warranted, and in fact can be slower, because the entire table
has to be loaded and sorted for each report run.
By default, SQR lets the database sort the data. This works fine if the database and
SQR both use the same character set and collating sequence. The SORT argument
enables you to specify the sorting method if this is not true. Additionally, if the machine
that SQR is running on is faster than the machine the database is running on, letting
SQR perform the sort could decrease the execution time of the report.
The only limit to the size of a lookup table is the amount of memory your computer has
available. You could conceivably load an array with many thousands of rows. The binary
search is performed quickly regardless of how many rows are loaded.
Except for the amount of available memory, there is no limit to the number of lookup
tables that can be defined.
An array is a collection of data storage locations, each of which holds the same type of
data. Each storage location is called an element of the array. When you create an array,
you don't have to declare the size of the array at declaration time. Arrays grow and
shrink dynamically as you add (or remove) data. The size of an array is limited by the
available memory. You can't access past the end of an array, but you can assign outside
the existing boundaries, thereby growing the array.
An array object can only be instantiated from PeopleCode. This object can be used
anywhere you have PeopleCode, that is, in message subscription PeopleCode,
Component Interface PeopleCode, record field PeopleCode, and so on.
22. What are important and compulsory SQC's (setenv.sqc)
A. It includes the RDBMS, Operating System; File prefix/suffix DEFINES files and
initializations values to setting the environments like Process Scheduler, Global
Delimiter, Printer and Language. Setenv.sqc for setting environment
23. What is the extension of list file in sqr?
A. SQR programs list file usually have a file extension of lis
24. What is the extension of sqr?
A. SQR programs usually have a file extension of .sqr.
There are a number of reasons to use break logic in a report. It enables you to:
Add white space to your reports.
Avoid printing redundant data.
Perform conditional processing on variables that change.
Print subtotals.
In the following program, the ON-BREAK option of the PRINT command accomplishes
two related tasksit starts a new group each time the value of state changes, and prints
state only when its value changes. Note that ON-BREAK works as well for implicit as for
explicit PRINT commands, such as in the following example, where state, city, name,
and phone are implicitly printed as part of the SELECT paragraph.
SKIPLINES You can further enhance the visual effect of break processing by inserting
one or more lines between groups. To do so, use the SKIPLINES qualifier with ONBREAK.
DECLARE-LAYOUT Defines the attributes for the layout of an output file.
The DECLARE-LAYOUT command describes the characteristics of a layout to be used
for an output file. A layout can be shared by more than one report. If no DECLARELAYOUT is defined or if a DECLARE-REPORT does not reference a defined layout, a
layout named DEFAULT is created with the default attribute values shown in the
DECLARE-LAYOUT Command Arguments table.
You can define as many layouts as are necessary for the requirements of the
application. You can override the DEFAULT layout attributes by defining a layout called
DEFAULT in your program. Each layout name must be unique.
ON-ERROR Begin-Select declares a procedure to execute if an error occurs due
to incorrect SQL syntax. Error trapping should be used in conjunction with dynamic
query variables. SELECT paragraphs without dynamic variables are checked for errors
before the program is processed and therefore do not require a special error procedure.
You can optionally specify arguments to be passed to the ON-ERROR procedure.
Arguments can be any variable, column, or literal.
Error To reference or declare global variables from a local procedure, add a leading
underscore to the variable name, after the initial $, #, or &. (Example: #_amount)
Note. All the SQR reserved variables, such as #sql-status and $sql-error, are global
variables. Within a local procedure, they must be referenced using the leading
underscore: #_sql-status or $_sql-error.
38. Which is the sqc for date, heading, landscape and portrait?
A. SetLyOut.sqc set the layout for the SQR report.
Overrides the printer defaults for the specified printer type.
Each printer has a set of defaults as listed in the DECLARE-PRINTER Command
Arguments table. The DECLARE-PRINTER command overrides these defaults.
Use the DECLARE-PRINTER command in the SETUP section to define the
characteristics of the printer or printers to be used. If you need to change some of the
arguments depending on the runtime environment, you can use the ALTER-PRINTER
command in any part of the program except the PROGRAM and SETUP sections.
A program can contain no more than one DECLARE-PRINTER command for each
printer type for each report. If you do not provide a printer declaration, the default
specifications are used. The default printer attributes can be overridden by providing a
DECLARE-PRINTER specification for each printer. Their names are: DEFAULT-LP for
line printer, DEFAULT-HP for HP LaserJet, DEFAULT-HT for HTML, and DEFAULT-PS
for PostScript.
39. While writing sqr two tables need to be joined and is it possible to join two tables with
non-key tables columns?
A. There is a possible chances of Join two tables with non-key table columns, the two
tables should have the same column representations and with equalizations values.
A join is created when you select data from more than one database table in the same
SELECT paragraph.
Procedure arguments are treated as local variables. Arguments can be numeric, date, or
text variables or strings. If an argument is preceded with a colon, its value is passed
back to the calling procedure.
In the following example, spell_number takes two arguments. The first argument is the
check amount. This argument is a number, and the program passes it to the procedure.
There is no need for the procedure to pass it back.
The second argument is the result that the procedure passes back to the calling
program. We precede this variable with a colon, which means that the value of this
argument is copied back at the end of the procedure. The colon is only used when the
argument is declared in the BEGIN-PROCEDURE command.
Look at the following code. It is not a complete program, but it is the spell_number
procedure, which is stored in the file spell.inc. The check-printing program includes this
code using an #INCLUDE command.
File spell.inc
begin-procedure spell_number(#num,:$str)
40. Is there any SQR or other program, which lists the number of tables and steps
referenced in a given App. Engine program?
A. This SQL will assist you to give the number of steps involved in the App. Engine:
SELECT A.AE_APPLID, COUNT(*)
FROM PSAESTEPDEFN A
WHERE A.EFFDT =
(SELECT MAX(A_ED.EFFDT) FROM PSAESTEPDEFN A_ED
WHERE A.AE_APPLID = A_ED.AE_APPLID
AND A.AE_SECTION = A_ED.AE_SECTION
AND A.MARKET = A_ED.MARKET
AND A.DBTYPE = A_ED.DBTYPE
AND A_ED.EFFDT <= SYSDATE)
AND A.AE_APPLID =
GROUP BY A.AE_APPLID
PeopleSoft delivers an SQR Report called TBLUSAGE.
In the web-client (Financials 8.4 SP1, PeopleTools 8.43.07) you can access the Run
Control page for this process at Setup Financials/Supply Chain, Utilities, Tables
Accessed and Updated. This process will create a list of tables for an SQR, App. Engine,
COBOL or Query.
Here is a good sample of how to launch an SQR from within PeopleCode. You can use
the peoplecode function called
!---------------------------------------!- BEGIN PEOPLESOFTPROS.NET CODE SAMPLE
!---------------------------------------&&PROCESS_NAME = "SQRNAME";
&&PROCESS_TYPE = "SQR Report";
&&RUN_CNTL_ID = "YOUR_RUN_ID";
&&RUN_CONTROL = ScheduleProcess(&PROCESS_TYPE, &&PROCESS_NAME, "2",
&RUN_CNTL_ID, &PRCS_INST);
If &&RC != 0 /*"1" = client "2" = server */
Winmessage("Error: Error Scheduling SQR Process, RC="/&RUN_CONTROL);
End-If;
1. What is an SQC? OR What are sqc's?
2. What sqc's are used for error processing?
===============================SQR================================
The data source is specified using the DATA-ARRAY option. The named array has a
structure that is specified by the TYPE option. For a stacked-bar chart, the first field
in the array gives the names of the categories for the bars. The rest of the fields are
series of numbers. In this case, each series corresponds to a month.
The subtitle goes under the title and can be used as a second line of the title. A
legend labels the series. The DATA-ARRAY-COLUMN-LABELS argument passes
these labels. The argument DATA-ARRAY-ROW-COUNT is the number of rows
(bars) to chart and DATA-ARRAY-COLUMN-COUNT is the number of fields in the
array that the chart uses. The array has four fieldsthe product (or price category)
field and the series that specifies three months.
To select a font in SQR for PeopleSoft, you use the commands DECLARE-PRINTER
and ALTER-PRINTER. The DECLARE-PRINTER command sets the default font for
the entire report. The ALTER-PRINTER command changes the font anywhere in the
report and the change remains in effect until the next ALTER-PRINTER.
If you want to set a font for the entire report, use ALTER-PRINTER, which is not
printer-specific, at the beginning of the program. If you are writing a printerindependent report, be aware that the attributes you set with DECLARE-PRINTER
take effect only when you print your report with the printer you specify with the TYPE
argument. To specify a printer at print time, use the -PRINTER:xx command-line flag.
When you use a proportionally spaced font, the number of letters that you print may
no longer match the number of character cells that the text actually fills. For example,
in the following sample code, the word "Proportionally" fills only 9 cells, although it
contains 14 letters.
When you print consecutive text strings, the actual position at the end of a string may
differ from the position SQR assumes according to the grid. For this reason, we
advise you to concatenate consecutive pieces of text and print them as one.
The WRAP and CENTER options of the PRINT command also require special
consideration when used with proportional fonts. They both calculate the text length
based on the character count in the grid, which is not the same as its dimensional
width. The use of these options with proportional fonts is explained after the output
example.
The WRAP option of the PRINT command prints the text of the reminder column.
This option wraps text based on a given width, which is 60 characters in the sample
program. The WRAP option works only on the basis of the width given in the
character grid. It does not depend on the font.
DECLARE-PRINTER is printer-specific fonts. ALTER-PRINTER is printer-neutral
fonts.
The BOLD, CENTER, and WRAP options of the PRINT command format text.
The INPUT command prompts the user to enter the printer type. Because the USEPRINTER-TYPE command does not accept a variable as an argument, the
EVALUATE command is used to test for the six possible values and set the printer
type accordingly.
The EVALUATE command is similar to a switch statement in the C language. It
compares a variable to multiple constants and executes the appropriate code
The SQL language supports the use of variables. An SQL statement containing
variables is considered static. When SQR executes this statement several times, it
executes the same statement, even if the values of the variables change. Because
SQL only allows variables in places where literals are allowed (such as in a WHERE
clause or INSERT statement), the database can parse the statement before the
values for the variables are given.
Note the use of the $state variable in the SELECT paragraph. When you use a
variable in a SQL statement in SQR for PeopleSoft, the SQL statement sent to the
database contains that variable. SQR "binds" the variable before the SQL is
executed. In many cases, the database only needs to parse the SQL statement
once. The only item that changes between executions of the SELECT statement is
the value of the variable. This is the most common example of varying a SELECT
statement.
In this program, the INPUT command prompts the user to enter the value of state.
The arguments MAXLEN and TYPE check the input, ensuring that the user enters a
string of no more than two characters. If the entry is incorrect, INPUT re-prompts.
You may find the restriction against using variables where only literals are allowed
somewhat restrictive. In the following example, the ordering of the records, changes
based on the user's selection. The program runs the SELECT twice. The first time,
the first column is called name and the second column is called city, and the program
sorts the records by name with a secondary sort by city. The second time, the first
column is the city and the second is name, and the program sorts by city with a
secondary sort by name. SQR constructs the statement each time before executing
it. This technique is called dynamic SQL
When you use variables in a SQL statement in SQR to replace literals and more, you
make them dynamic variables by enclosing them in square brackets. For example,
when you use the dynamic variable [$my_order] in the ORDER BY clause of the
SELECT statement, SQR places the text from the variable $my_order in that
statement. Each time the statement is executed, if the text changes, a new statement
is compiled and executed.
SQR for PeopleSoft checks and reports database errors for SQL statements. When
an SQR program is compiled, SQR checks the syntax of the SELECT, UPDATE,
INSERT, and DELETE SQL statements in your program. Any SQL syntax error is
detected and reported at compile time, before the execution of the report begins.
When you use dynamic SQL, SQR cannot check the syntax until runtime. In that
case, the content of the dynamic variable is used to construct the SQL statement,
which can allow syntax errors to occur in runtime. Errors could occur if the dynamic
variables selected or used in a WHERE or ORDER BY clause were incorrect.
SQR traps any runtime error, reports the error, and ends the program. If you want to
change this default behavior, use the ON-ERROR option of the BEGIN-SELECT or
BEGIN-SQL paragraphs.
This procedure displays the error message but does not end the execution of the
program. Instead, execution continues at the statement immediately following the
SQL or SELECT paragraph. Note the use of the variable $sql-error, which is a
special SQR reserved variable. It contains the error message text from the database
and is automatically set by SQR after a database error occurs.
SQR has a number of reserved, or predefined, variables. For example, the variable
$sqr-program has the name of the program that is running. The variable $username
has the user name that was used to log on to the database. The variable #pagecount has the page number for the current page.
In the following program, the ASK command in the SETUP section prompts the user
at compile time. The value that the user enters is placed in a special kind of variable
called a substitution variable. This variable can be used to substitute any command,
argument, or part of a SQL statement at compile time. You can use substitution
variables entered by the ASK command in place of any command, argument, or SQL
statement at compile time. Enclosed these in curly braces.
You can use the ASK command only in the SETUP section. SQR executes ASK
commands at compile time before program execution begins. Therefore, all ASK
commands are executed before any INPUT command.
Input is more flexible than ASK. You can use INPUT inside loops. You can validate
the length and type of data input and re-prompt if it is not valid. There is an example
of re-prompting in "Using Variables in SQL".
ASK can be more powerful. Substitution variables set in an ASK command let you
modify commands that are normally quite restrictive.
SQR procedures that contain variables that are visible throughout the program are
called global procedures. These procedures can also directly reference any program
variable.
When you create library procedures that can be used in many programs, make them
local. Then, if a program has a variable with the same name as a variable used in the
procedure, there will not be a collision. SQR treats the two variables as separate.
PeopleSoft recommends that you declare a procedure as local even if it does not
take any arguments. To do this, place the keyword LOCAL after the procedure name
in the BEGIN-PROCEDURE command.
To reference a global variable from a local procedure, insert an underscore between
the prefix character (#, $, or &) and the variable name. Use the same technique to
reference reserved variables such as #current-line. These variables are always
global, that you can reference from a local procedure.
SQR supports recursive procedure calls, but it maintains only one copy of a local
variable. A procedure does not allocate new instances of the local variables on a
stack, as C or Pascal would.
Procedure arguments are treated as local variables. Arguments can be either
numeric, date, or text variables or strings. If an argument is preceded with a colon, its
value is passed back to the calling procedure.
Variables in global procedures are visible throughout the program.
Variables in local procedures are visible only within the procedure.
To reference a global variable from a local procedure, place an underscore between
the prefix character #, $, or & and the variable name.
To pass an argument back to its calling procedure, preface it with a colon.
This feature can save a significant amount of processing time. You can create
multiple reports based on common data, selecting the database records only once
and creating different reports simultaneously.
The alternativewriting separate programs for the different reportswould require
you to perform a separate database query for each report. Repeated queries are
costly because database operations are often the most resource-consuming or timeconsuming part of creating a report.
The FOR-REPORTS option of the BEGIN-HEADING and BEGIN-FOOTING
commands specifies the report name. The parentheses are required. Note that the
USE-REPORT command is not needed in the heading or the footing. The report is
implied by the FOR-REPORTS option
When you run ex18a.sqr, you get three output files that match the output files for
ex9a, ex10a, and ex3a, respectively. These output files have the names ex18a.lis
(labels), ex18a.l01 (form letter), and ex18a.l02 (customer listing). If you specify
-KEEP, the output files are named ex18a.spf, ex18a.s01, and ex18a.s02,
respectively.
USE-REPORT sets the printing context for each report.
Although SELECT may be the most common SQL statement, you can also perform
other SQL commands in SQR. Here are a few examples:
o If the program prints important documents such as checks, tickets, or invoices,
you may need to update the database to indicate that the document was printed.
You can do this in SQR with a SQL UPDATE statement.
o You can use SQR to load data into the database. SQR can read and write
external files and construct records. SQR can also insert these records into the
database using a SQL INSERT statement.
o If you need to hold intermediate results in a temporary database table, you can
create two SQL paragraphs in your SQR program (CREATE TABLE and DROP
TABLE) to create this table at the beginning of the program and drop the table at
the end.
The program reads the records from the file and inserts each record into the
database by using an insert statement inside a BEGIN-SQL paragraph. The input file
format is one record per line, with each field separated by the separator character.
When the end of the file is encountered (if #end-file), the program branches out of
the loop. Note that #end-file is an SQR reserved variable.
The final step is to commit the changes to the database and close the file. You do
this with a SQL COMMIT statement inside a BEGIN-SQL paragraph. Alternatively,
you can use the SQR COMMIT command. For Oracle databases, we recommend
you use the SQR COMMIT.
To begin accessing the data from the CSV Data Source, Declare-Connection must
be established to a registered data source. See DDO Registry Properties.
o Enter Declare-Connection followed by a connection_name_literal CSV.
o Enter DSN, this is the logical data source name as recorded in the DDO Registry.
When creating queries, it is often helpful to view the structure of the CSV file that you
are querying. You can browse a CSV file's metadata, that is, information about the
file's structure, by running the DDO Query Editor and selecting a schema in the
Schema View drop-down list box and viewing its selectable column list.
You construct queries in the same manner you access relational databases. You can
choose a sample script from the Samples directory and run or modify it, or construct
your own. The scripts in the sample directory are included when the SQR-DDO port
is installed. You can edit this file with a text editor or create files of your own. To
properly access a CSV data source, a Data Object must be defined. The data object
is declared after the Begin-Execute command and prior to the Begin-Select
command. For CSV queries, the DDO GetData paradigm is used for data access.
Date values can be obtained in one of five ways:
To extend SQR, add functions to the userfuncs global array in the UFUNC.C file.
SQR supports XML.
During the development of an SQR program, you frequently test it by running it and
examining its output. Often, you are interested only in the first few pages of the
report.
To speed up the cycle of running and viewing a few pages, use the -T command-line
flag. The -T flag enables reports to finish more quickly because all BEGIN-SELECT
ORDER BY clauses are ignored. The database does not sort the data and the first
set of records are selected sooner. Enter the desired number of test pages after the
-T flag. For example, -T6 causes the program to stop after six pages of output have
been created.
Note. If your program contains break logic, the breaks can occur in unexpected
locations because the ORDER BY clause is ignored.
When debugging a program it is often useful to:
o Display data or show when a procedure or query executes by using temporary
SHOW or DISPLAY commands in key places in the program.
o Isolate problem areas by temporarily skipping the parts of the program that work
correctly.
o Temporarily cause additional behavior in questionable areas of the program. For
example, display or modify variables that you suspect are causing a problem.
SQR provides the #DEBUG command to help you make temporary changes to your
code. You can use the #DEBUG command to conditionally process portions of your
program.
When the #DEBUG precedes a command, that command is processed only if the
-DEBUG flag is specified on the SQR command line. In this example, the value of $s
is displayed only when you run the program with -DEBUG.
You can obtain multiple debug commands by using up to 10 letters or digits to
differentiate between them. Indicate which command is to be debugged on the
-DEBUG flag,
You can conditionally compile entire sections of your program using the five compiler
directives: #IF, #ELSE, #END-IF or #ENDIF, #IFDEF, #IFNDEF
You can use the value of a substitution variable, declared by a #DEFINE command,
to activate or deactivate a set of statements. By defining DEBUG_SESSION as Y,
the dump_array procedure is included in the program. Later, you can change
DEBUG_SESSION to N and exclude the dump_array procedure from the program.
The #IF command in this example is case-insensitive.
Whenever your programs contain a BEGIN-SELECT, BEGIN-SQL, or EXECUTE
command, it performs an SQL statement. Processing SQL statements typically
consumes significant computing resources. Tuning SQL statements typically yields
higher performance gains than tuning any other part of your program.
With relational database design, information is often "normalized" by storing data
entities in separate tables. To display the normalized information, you must write a
SELECT statement that joins these tables together. With many database systems,
performance suffers when you join more than three or four tables in one SELECT.
With SQR, you can perform multiple SELECT statements and nest them as we
indicated in the "Master/Detail Reports" chapter. In this way, you can break a large
join into several simpler SELECTS. For example, you can break a SELECT
statement that joins orders and products tables into two SELECTS. The first
SELECT retrieves the orders in which we are interested. For each order retrieved, a
second SELECT retrieves the products that were ordered.
With LOAD-LOOKUP, you can reduce the number of tables that are joined in one
SELECT. Use this command in conjunction with one or more LOOKUP commands.
The LOAD-LOOKUP command defines an array containing a set of keys and values
and loads it into memory. The LOOKUP command looks up a key in the array and
returns the associated value. In some programs, this technique performs better than
a conventional table joins. You can use LOAD-LOOKUP in the SETUP section or in a
procedure. If used in the SETUP section, it is processed only once. If used in a
procedure, it is processed each time it is encountered. LOAD-LOOKUP retrieves two
fields from the database, the KEY field and the RETURN_VALUE field. Rows are
ordered by KEY and stored in an array. The KEY field must be unique and contain no
NULL values. When the LOOKUP command is used, the array is searched (using a
"binary" search) to find the RETURN_VALUE field corresponding to the KEY
referenced in the lookup.
Which is faster, a database join or LOAD-LOOKUP? It depends on your program.
LOAD-LOOKUP improves performance in the following situations:
o When it is used with multiple SELECTS.
o When it keeps the number of tables being joined from exceeding three or four.
o When the number of entries in the LOAD-LOOKUP table, is small compared to
the number of rows in the SELECT, and they are used often.
o When most entries in the LOAD-LOOKUP table, are used.
Note. You can concatenate columns if you want RETURN_VALUE to return more
than one column. The concatenation symbol is database-specific.
Programs often use temporary database tables to hold intermediate results.
Creating, updating, and deleting database temporary tables are a very resourceconsuming task, however, and can slow your program's performance. SQR provides
two alternatives to using temporary database tables.
The first alternative is to store intermediate results in an SQR array. The second is to
store intermediate
Compiling your SQR program can improve its performance. The compiled program is
stored in a runtime (.SQT) file. You can then run it with SQR Execute. Your program
runs faster because it skips the compile phase.
When a BEGIN-SELECT command is executed, records are fetched from the
database server. To improve performance, they are fetched in groups rather than one
at a time. The default is groups of 10 records. The records are buffered, and your
program processes these records one at a time. A database fetch operation is
therefore performed after every 10 records, instead of after every single record. This
is a substantial performance gain. If the database server is on another computer,
then network traffic is also significantly reduced.
The number of records to fetch together can be modified using the -B command-line
flag or for an individual BEGIN-SELECT command using its -B option. In both cases,
you specify the number of records to be fetched together. For example -B100
specifies that records be fetched in groups of 100. This means that the number of
database fetch operations is further reduced.
Use dynamic SQL instead of a condition in a SELECT statement
Adjust settings in the [Processing-Limits] section of PSSQR.INI or in a startup file.
Execute programs on the database server machine
SQR enables you to save the compiled version of a program and use it when you
rerun a report. That way, you perform the compile step only once and skip it in
subsequent runs. Note that SQR does not compile the program into machine
language. SQR creates a ready-to-execute version of your program that is already
compiled and validated. This file is portable between different hardware platforms
and between some databases.
Run the SQR executable ("sqr" or "sqrw") with the -RT command-line flag to execute
the .SQT file. Execution is faster because the program is already compiled. Here is
an example: sqrw ex1a.sqt sammy/baker@rome -RT
The SQR product distribution includes SQR Execute (the SQRT program). SQR
Execute can run .sqt files, but does not include the code that compiles an SQR
program. (This program is equivalent to running SQR with -RT.) You can run the .sqt
file by invoking SQR Execute from the command line with "sqrt" (on UNIX systems)
or "sqrwt" (on Windows systems). An example of running SQR Execute from the
command line is as follows: sqrwt ex1a.sqt sammy/baker@rome
Note that after you save the run-time (.sqt) file, SQR no longer performs any
compile-time steps such as executing #IF, #INCLUDE, or ASK commands or
performing the SETUP section. These were already performed at the time that the
program was compiled and the runtime file was saved.
You must make a clear distinction between what is performed at compile time and
what is performed at runtime. Think of compile-time steps as defining what the report
is. Commands such as #IF or ASK enable you to customize your report at compile
time. For runtime customization, you should use commands such as IF and INPUT.
To save a compiled version of an SQR program, use the -RS command-line flag.
To run a precompiled program, use the -RT command-line flag or SQR Execute.
Except on the Microsoft Windows platform, SQR does not actually print the report.
SQR creates an output file that contains the report, but it does not print it directly.
The output file can be a printer-specific file or an SQR portable file (SPF). SQR
portable files have a default extension of .spf or .snn (for multiple reports).
SQR portable file (.spf) is a printer-independent file format that supports all the SQR
graphical features, including fonts, lines, boxes, shaded areas, charts, bar codes,
and images.
This file format is useful for saving the output of a report. SPF files can be distributed
electronically and read with the SQR Viewer. Producing SPF output also enables you
to decide later where to print it. Use SQR Viewer or SQR Print to print an SPF file.
Command-line flags create output files appropriate for different platforms and
printers.
DECLARE-PRINTER specifies printer-specific settings, but it does not itself cause
the report to be prepared for a specific printer.
To prepare a report for a specific printer, use the -PRINTER:xx command-line flag,
the USE-PRINTER-TYPE command, or the DECLARE-REPORT command with the
printer-type option.
The -F command-line flag enables you to name output files (including file
extensions).
The -NOLIS and -KEEP command-line flags create files in SQR portable format with
an .spf extension.
Specify multiple arguments in an argument file referenced on the command line.
Use a question mark on the command line to prompt a user for input.
Use batch mode to run multiple programs.
The BEGIN-SELECT command is the principal method of retrieving data from the
database and printing it in a report. Look again at the list_customers procedure,
which starts with BEGIN-PROCEDURE and ends with END-PROCEDURE. Note the
comment following the END-PROCEDURE command. It indicates that the procedure
is being ended, which is helpful when you have a program with many procedures.
(You can also omit the exclamation point: END-PROCEDURE main.)
The procedure itself contains a select paragraph, which starts with BEGIN-SELECT
and ends with END-SELECT.
In a SELECT statement (repeated here), you see positioning after each column
name. This positioning implies a PRINT command for that column. As before,
omitting the line number in the position causes it to be set by default to the current
line.
The implied PRINT command is a special SQR feature designed to save you coding
time. It works only inside a SELECT paragraph. After the last column, there is a
POSITION command: POSITION(+1). The plus sign (or minus sign) indicates
relative positioning in SQR. A plus sign moves the print position forward from the
current position, and a minus sign moves it back. The "+1" in our program specifies
one line down from the current line. This command advances the current print
position to the next line. Note. When you indicate print positions using plus or minus
signs, be sure your numbers do not specify a position outside the page boundaries.
In a SELECT statement, you can print a column by entering it at the beginning of a
line with a position qualifier. This is called an implied PRINT command.
SQR Print enables you to create printer-specific reports for any of the file types
supported by SQR. SQR Print converts portable printer-independent files (SPF) into
printer-specific files. SQR and SQRT create SPF files when you use the -KEEP and
-NOLIS command line flags.
Grid Adds a grid that looks and behaves like a spreadsheet that is embedded in a
page. It has column headings and cells and uses push buttons, links, and tabs to
navigate through the data. It is similar to a scroll area on a page. Each row in the grid
corresponds to a set of controls in a scroll occurrence. Navigation links and push buttons
replace the actual visual scroll bar, and add and delete push buttons enable a user to
insert and delete rows. Use instead of a single-level scroll area or scroll bar to manage
multi-row sets of data.
Scroll Area Provides an easy way for you to group or repeat multiple fields of data in a
defined area. Like a grid, users can easily navigate through the rows using links and
buttons in a navigation bar, and they can add or delete rows using push buttons. These
features are automatically placed in the navigation bar. The navigation bar also provides
several other settings, such as a Find feature that enables the user to search all fields
and rows for specific data and a View All option so that the user can see all rows of data
at once.
The fields in the scroll area can be placed randomly, one on top of the other, or side-byside. Unlike a grid, you are not limited to the type of controls that you can place in your
scroll area. You can even place a grid inside a scroll area.
Scroll Bar Like the scroll area, scroll bars also contain push buttons and links for
navigation, but not in the form of navigation bars. Developers must manually position all
navigation items. Like grids and scroll areas, the actual scroll control that you see in
PeopleSoft Application Designer when working with scroll bars in page definitions does
not appear at runtime. Instead, the scroll bar control has scroll action buttons to replace
the visual rendering of the scroll bar as push buttons and links on the web.
Secondary Page Adds an invisible control that associates a secondary page with the
primary page. You then associate the secondary page with a command push button or
link or a pop-up menu. Secondary pages gather or display supplemental information that
is related to the data in a primary page but less frequently referenced or updated.
Secondary pages are displayed using the DoModal PeopleCode function.
HTML Area Adds an area where you can write your own HTML. With other controls,
the PeopleSoft system automatically generates the HTML code. The HTML code is then
inserted into the dynamically generated code at runtime.
Push Button or Link Adds a push button or link that represents an internal or external
link, PeopleCode command, process through PeopleSoft Process Scheduler, prompt
action, scroll action, secondary page, or toolbar action. You can specify whether the
control appears as a traditional push button, or as a link (highlighted, underlined text).
Derived and Work Fields You can use a field definition from a derived or work record to
store a temporary value that PeopleCode uses to determine the values of other field
controls on the page.
For example, for a budgeting transaction in PeopleSoft General Ledger, assume that you
have an annual amount that you must spread to multiple accounting periods. You can
create a page that includes both a field control from a derived record for the annual
amount and an amount control for each accounting period. You then write PeopleCode to
derive the amount per accounting period from the annual amount. When a user enters
the annual amount in the derived field control, PeopleCode calculates the amount per
accounting period and inserts it into each accounting period field control. The annual
amount isn't stored in the database, but the period amounts are.
PeopleSoft applications can run in two different processing modes: interactive and
deferred.
Interactive Mode In interactive mode (formerly called standard), when the user exits a
field that has a field-level event (for example, FieldChange, FieldEdit, RowInsert
PeopleCode, prompt validation, related display, and so on):
A transmission to the application server is performed to run that field-level event.
The page is redisplayed.
Deferred Mode Deferred mode enables you to defer many of the conditions that need
server processing until running them on the application server is required or requested.
For example, when a user exits a field that has a field-level event (like FieldChange or
FieldEdit PeopleCode, prompt validation, related display, and so on) that event is not run
until the next transmission to the application server. When the next transmission to the
server occurs, PeopleTools determines which fields have changed since the last
transmission. Logic on the application server runs the appropriate system edits and
PeopleCode events (in field layout order).
You can select deferred mode processing at the field, page, and component levels. For a
field in the component to run in deferred mode, you must select deferred mode at each
of those levels. Deferred processing is the default mode at the field, page, and
component levels.
About SQC find some info: Home PeopleBooks Library PeopleSoft Process
Scheduler Appendix A: Using Process Request APIs
Home PeopleBooks Library Data Management Understanding Configuration
Manager