Was this helpful?
Command Line Operations
The following sections describe how to turn an embedded ESQL/Pascal source program into an executable program. These sections include commands that preprocess, compile, and link a program.
esqlp – Invoke Embedded SQL Preprocessor for Pascal
The Pascal preprocessor is invoked by the following command line:
esqlp {flags} {filename}
where flags are
Flag
Description
-d
Adds debugging information to the runtime database error messages generated by Embedded SQL. The source file name, line number and statement in error will be printed with the error message.
-f[filename]
Writes preprocessor output to the named file. If no filename is specified, the output is sent to standard output, one screen at a time.
-l
Writes preprocessor error messages to the preprocessor's listing file, as well as to the terminal. The listing file includes preprocessor error messages and your source text in a file named filename.lis, where filename is the name of the input file.
-lo
Like -l, but the generated Pascal code also appears in the listing file.
-o.ext
Specifies the extension given by the preprocessor to both the translated include statements in the main program and the generated output files.
If this flag is not provided, the default extension is ".pas."If you use this flag in combination with the -o flag, then the preprocessor generates the specified extension for the translated include statements, but does not generate new output files for the include statements.
-o
Directs the preprocessor not to generate output files for include files. This flag does not affect the translated include statements in the main program. The preprocessor will generate a default extension for the translated include file statements unless you use the -o.ext flag.
-?
Shows what command line options are available for esqlp.
-s
Reads input from standard input and generates Pascal code to standard output. This is useful for testing statements you are not familiar with. If the -l option is specified with this flag, the listing file is called "stdin.lis." To terminate the interactive session, type Ctrl Z.
-sqlcode
Indicates the file declares ANSI SQL code.
The ANSI-92 specification describes SQLCODE as a "deprecated feature" and recommends using the SQLSTATE variable.
-[no]sqlcod
Tells the preprocessor not to assume a declared SQLCODE is for ANSI status information.
-w
Prints warning messages.
-wopen
This flag is identical to -wsql=open. However, -wopen is supported only for backwards capability. For more information, see -wsql=open.
-wsql=
entry_SQL92open
Prints warning messages that indicate all non-entry SQL92 compliant syntax.
Use open only with OpenSQL syntax. -wsql = open generates a warning if the preprocessor encounters an Embedded SQL statement that does not conform to OpenSQL syntax. (OpenSQL syntax is described in the OpenSQL Reference Guide.) This flag is useful if you intend to port an application across different Ingres Gateways. The warnings do not affect the generated code and the output file may be compiled. This flag does not validate the statement syntax for any SQL Gateway whose syntax is more restrictive than that of OpenSQL.
The Embedded SQL/Pascal preprocessor assumes that input files are named with the extension ".sp." You can override this default by specifying the file extension of the input file(s) on the command line. The output of the preprocessor is a file of generated Pascal statements with the same name and the extension ".pas."
If you enter the command without specifying any flags or a filename, Ingres displays a list of flags available for the command.
esqlp Command Options
The following table presents the command options available with esqlp.
Command
Comment
esqlp file1
Preprocesses "file1.sp" to "file1.pas"
esqlp file2.xp
Preprocesses "file2.xp" to "file2.pas"
esqlp -l file3
Preprocesses "file3.sp" to "file3.pas" and creates listing "file3.lis"
esqlp -s
Accepts input from standard input
esqlp -ffile4.out file4
Preprocesses "file4.sp" to "file4.out"
esqlp
Displays a list of flags available for this command
The Pascal Compiler
As mentioned above, the preprocessor generates Pascal code. You should use the VMS pascal command to compile this code. You can use most of the pascal command line options. You must not use the g_floating qualifier if real variables in the file are interacting with Ingres floating-point objects. You should also not use the old_version qualifier, because the preprocessor generates code for Version 3. Note, too, that many of the statements that the Embedded SQL/Pascal preprocessor generates are non-standard extensions provided by VAX/VMS. Consequently, you should not use the standard qualifier.
The following example preprocesses and compiles the file "test1." Note that both the Embedded SQL preprocessor and the Pascal compiler assume the default extensions.
$ esqlp test1
$ pascal/list test1
VMS:
As of Ingres II 2.0/0011 (axm.vms/00) Ingres uses member alignment and IEEE floating-point formats. Embedded programs must be compiled with member alignment turned on. In addition, embedded programs accessing floating-point data (including the MONEY data type) must be compiled to recognize IEEE floating-point formats.
The VMS default qualifier /g_float is not a standard and should not be used.
On Alpha systems, hardware support for D_float is only partial, the default has changed to G_float, and support for IEEE (IEEE 754-1985 standard for floating point arithmetic) has been added. Because of this, and because IEEE is available on other platforms and is recognized as an industry standard, Ingres for OpenVMS Alpha uses the IEEE format.
All programs and libraries should be compiled using the IEEE qualifier. Do not mix programs or libraries compiled with different qualifiers.
For example:
esqlp prog.sp
pascal /float=ieee prog
Failure to use the /float=ieee qualifier or the use of non-IEEE float numbers will result in unpredictable results when non-IEEE floats are used as keys or in restrictions.
Note:  Check the Readme file for any operating system specific information on compiling and linking ESQL/Pascal programs.
How Embedded SQL Programs are Linked
Embedded SQL programs require procedures from several VMS shared libraries in order to run properly. Once you have preprocessed and compiled an Embedded SQL program, you can link it. Assuming the object file for your program is called "dbentry," use the following link command:
$ link dbentry,-
  ii_system:[ingres.files]esql.opt/opt
Link Precompiled Forms
The technique of declaring a precompiled form to the FRS is discussed in the SQL Reference Guide and in The SQL Communications Area. To use such a form in your program, you must also follow the steps described here.
To link a form
1. In VIFRED, select a menu item to compile a form. VIFRED then creates a file in your directory describing the form in the VAX-11 MACRO language. Select a name for the file.
2. Once you have created the MACRO file, assemble it into linkable object code with the VMS command:
macro filename
3. The output of this command is a file with the extension ".obj". Link this object file with your program by listing it in the link command, as in the following example:
$ link formentry,-
  empform.obj,-
  ii_system:[ingres.files]esql.opt/opt
How to Link Embedded SQL Programs without Shared Libraries
While the use of shared libraries in linking Embedded SQL programs is recommended for optimal performance and ease-of-maintenance, non-shared versions of the libraries have been included in case you require them. Non-shared libraries required by Embedded SQL are listed in the esql.noshare options file. The options file must be included in your link command after all user modules. Libraries must be specified in the order given in the options file.
The following example demonstrates the link command of an Embedded SQL program called "dbentry" that has been preprocessed and compiled:
$ link dbentry,-
  ii_system:[ingres.files]esql.noshare/opt
User-written Embedded SQL Routines in Shareable Images
When you plan to place your code in a shareable image, note the following about the psect attributes of your global or external variables.
As a default, some compilers mark global variables as shared (SHR: every user who runs a program linked to the shareable image sees the same variable) and others mark them as not shared (NOSHR: every user who runs a program linked to the shareable image gets their own private copy of the variable).
Some compilers support modifiers you can place in your source code variable declaration statements to explicitly state which attributes to assign a variable.
The attributes that a compiler assigns to a variable can be overridden at link time with the psect_attr link option. This option overrides attributes of all variables in the psect.
Consult your compiler reference manual for further details.
Last modified date: 11/09/2022