Compiling Programs and Using SQR Execute

This chapter provides an overview of compile features and discusses how to compile and run an SQR program.

Click to jump to parent topicUnderstanding Compile Features

The following table lists SQR features that apply at compile time and their possible runtime equivalents. In some cases, no equivalent exists and you must work around the limitation. For example, you may have to use substitution variables with commands that require a constant and do not allow a variable. The chapter “Writing Printer-Independent Reports” includes an example that works around the limitation of the USE-PRINTER-TYPE command, which does not accept a variable as an argument.

See Writing Printer-Independent Reports.

Compile Time

Runtime

Substitution variables

Use regular SQR variables. If you are substituting parts of an SQL statement, use dynamic SQL instead.

See Using Dynamic SQL and Error Checking.

ASK

INPUT

#DEFINE

LET

#IF

IF

INCLUDE

No equivalent

DECLARE-LAYOUT, margins

No equivalent

Number of heading or footing lines

No equivalent

DECLARE-CHART

PRINT-CHART

DECLARE-IMAGE

PRINT-IMAGE

DECLARE-PROCEDURE

USE-PROCEDURE

DECLARE-PRINTER

ALTER-PRINTER (where possible)

USE (Sybase only)

-DB command-line flag

Click to jump to parent topicCompiling and Running an SQR Program

For the user, running an SQR program is a one-step process. For SQR, however, two steps are involved: compiling the program and running it. When compiling a program, SQR:

Note. Make sure that SQRBIN (defined in psprcs.cfg) is pointing to the correct location (PS_HOME/bin/SQR/<DB>/bin for Unix and PS_HOME/bin/sqrw/<DB>/BINW for Microsoft Windows) before executing an SQR program.

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 bypass it in subsequent runs. SQR does not compile the program into machine language. SQR creates a ready-to-run version of the program that is already compiled and validated. This file is portable between different hardware platforms and between some databases.

Run the SQR executable (SQR for UNIX/Linux or SQRW for Microsoft Windows) against the SQR program file and include the -RS command-line flag to save the runtime file. SQR creates a file with a file name extension of .sqt . You should enter something like this:

sqrw ex1a.sqr sammy/baker@rome -RS

Run the SQR executable with the -RT command-line flag to run the .sqt file. It runs 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.) Here is an example of running SQR Execute from the command line:

sqrwt ex1a.sqt sammy/baker@rome

After you save the runtime (.sqt) file, SQR no longer performs any compile-time steps such as running #IF, #INCLUDE, or ASK commands or performing the SETUP section. These were already performed when 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 adapt your report at compile time. For runtime adaptation, use commands such as IF and INPUT.