Compiling and Running an SQR Program

For users, 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:

  • Reads, interprets, and validates the program.

  • Preprocesses substitution variables and certain commands: ASK, #DEFINE, #INCLUDE, #IF, and #IFDEF.

  • Validates SQL statements.

  • Performs the SETUP section.

Note: Make sure that SQRBIN (defined in psprcs.cfg) points to the correct location (PS_HOME/bin/SQR/<DB>/bin for Unix and PS_HOME/bin/sqrw/<DB>/BINW for Microsoft Windows) before you run 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 it 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 clearly distinguish between what action is performed at compile time and what action is performed at runtime. Think of compile-time steps as defining what a 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.