Command Line Operations
The following sections describe how to turn an embedded SQL/Ada source program into an executable program. The commands that preprocess, compile, and link a program are also described.
esqla Command – Invoke Embedded SQL Preprocessor for Ada
The Embedded SQL/Ada preprocessor is invoked by the following command line:
esqla {flags} {filename}
where flags are
The Embedded SQL/Ada preprocessor assumes that input files are named with the extension ".sa". 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 Ada statements with the same name and the extension ".ada".
If you enter the command without specifying any flags or a filename, a list of flags available for the command is displayed.
esqla Command Options
The following table presents the command options available with esqla.
The ACS Environment and the Ada Compiler
The preprocessor generates Ada code. You can then use the VMS ada command to compile this code into your Ada program library.
The following sections describe the Ada program library and Embedded SQL programs.
How to Enter Embedded SQL Package Specifications
Once you have set up an Ada program library, you must add four Embedded SQL units to your library. The units are package specifications that describe to the Ada compiler all the calls that the preprocessor generates. The source for these units is in the files:
ii_system:[ingres.files]eqdef.ada
ii_system:[ingres.files]eqsqlca.ada
ii_system:[ingres.files]eqsqlda.ada
Once you have defined your current program library using the acs set library command, you should enter the three units into your program library by issuing the following commands:
copy ii_system:[ingres.files]eqdef.ada, eqsqlca.ada,-
eqsqlda.ada []
ada eqdef.ada,eqsqlca.ada,eqsqlda.ada
delete eqdef.ada.,eqsqlca.ada.,eqsqlda.ada
You do not have to take the last step if you intend to compile the closure of a particular program from the source files at a later date. However, you should not modify an Embedded SQL definition file if it is left in your directory.
You need only enter the four Embedded SQL units once into your program library. Of course, if a new release of Embedded SQL/Ada includes modifications to the files "eqdef.ada," "esqlca.ada," or "eqsqlda.ada," you should copy and recompile the files.
If you display the new unit information, you will find the four unit names "ESQL," "ESQLDA," "EQUEL," and "EQUEL_FORMS" in the library. For example, by issuing:
acs dir esql*,equel*
the three unit names will be displayed.
How to Define Long Floating-point Storage
The storage representation format of long floating-point variables must be d_float because the Ingres runtime system uses that format for floating-point conversions. If your Embedded SQL program has long_float variables that interact with the Embedded SQL runtime system, you must make sure they are stored in the d_float format. The default Ada format is g_float. A convenient way to control the format of all long float variables is to issue the acs set pragma program command. For example, by issuing the following command, you redefine the program library characteristics for long_float from the default to d_float:
acs set pragma/long_float=d_float
A second remedy to this particular problem is to issue the statement:
pragma long_float(d_float)
in the source file of each compilation unit that uses floating-point variables. You can also explicitly declare the Embedded SQL variables with type d_float, as defined in package SYSTEM.
The following example is a typical command file that sets up a new Ada program library with the Embedded SQL package specifications and the d_float numerical format. The name of the new program library is passed in as a parameter:
acs create library [.'p1']
acs set library [.'p1']
acs set pragma/long_float=d_float
copy ii_system:[ingres.files]eqdef.ada,eqsqlca.ada, -
eqsqlda.ada []
ada eqdef.ada,eqsqlca.ada,eqsqlda.ada
delete eqdef.ada.,eqsqlca.ada.,eqsqlda.ada
exit
The Ada Compiler
After you enter the Embedded SQL packages into the Ada program library, you can compile the Ada file generated by the preprocessor.
The following example preprocesses and compiles the file "test1." Note that both the Embedded SQL/Ada preprocessor and the Ada compiler assume the default extensions.
esqla test1
ada/list test1
Note: Refer to the Readme file for any operating system specific information on compiling and linking ESQL/Ada programs.
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:
esqla prog.sa
ada /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.
How Embedded SQL Programs are Linked
Embedded SQL/Ada programs require procedures from several VMS shared libraries in order to run. After you preprocess and compile an Embedded SQL/Ada program, you can link it. For example, if your program unit is called "dbentry," you can use the following link command:
acs link dbentry –
ii_system:[ingres.files]esql.opt/opt
Note that the Embedded SQL runtime library is not written in Ada, and therefore is specified as a foreign object file.
Link Precompiled Forms
The technique of declaring a precompiled form to the Forms Runtime System is discussed in the SQL Reference Guide. To use such a form in your program, you must also follow the steps described here.
To link a precomiled 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 MACRO language.
2. Once you have created the 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 specifying it in the link command as in the following example for the program unit "formentry," which includes two compiled forms:
acs link formentry –
empform.obj, deptform.obj, -
ii_system:[ingres.files]esql.opt/opt
How to Link Embedded SQL Programs without Shared Libraries
While the use of shared libraries in Embedded SQL programs is recommended for optimal performance and ease of maintenance, non-shared versions of the Embedded SQL runtime 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 local modules. Libraries must be specified in the order given in the options file.
The following example demonstrates the link command of the Embedded SQL program unit "dbentry," which has been preprocessed and compiled:
acs link dbentry –
ii_system:[ingres.files]esql.noshare/opt