Mimer SQL Documentation TOC PREV NEXT INDEX

Mimer SQL Developer Site


Processing MSQL


The following sections discuss pre-processing and processing MSQL.

Pre-processing - the MSQL command

An SQL module file must first be pre-processed using the MSQL command, then pre-processed using the ESQL command (see Processing ESQL), before it is compiled with the C compiler.

The input to the pre-processor is thus an SQL module written in Module language.

The output from the preprocessor is an Embedded C source code file, containing both C and ESQL statements.

The default file extensions for preprocessor input and output files are shown in the table below:

Input file extension
Output file extension
 .msq
 .ec

Invoking the MSQL Preprocessor

You invoke the MSQL preprocessor with the following command:

 $ msql [options] infile [outfile]

Options

Unix-style
VMS-style
Function
 -n
 --nologo
 /NOLOGO

Suppresses the display of the copyright message on the screen (warnings and errors are always displayed on the screen.)

Input-file and Output-file

Unix-style
VMS-style
Function
 infile
 infile

The input-file containing the SQL module source code to be pre-processed.

If no file extension is specified, the .msq file extension is assumed (previously described in this section.)

 [outfile]
 [outfile]

The output-file which will contain the Embedded C code generated by the preprocessor.

If not specified, the output file will have the same name as the input file, but with the .ec file extension (previously described in this section.)

Note: As an application programmer, you should never attempt to directly modify the output from the preprocessor.
Any changes that may be required in an SQL module should be introduced into the original SQL module code. Mimer Information Technology AB cannot accept any responsibility for the consequences of modifications to the pre-processed code.

What Does the Preprocessor Do?

The preprocessor checks the syntax (See [Handling Errors and Exceptions] for a more detailed discussion of how errors are handled). Syntactically invalid statements cannot be pre-processed and the source code must be corrected.

Processing MSQL

Compiling

The output from the MSQL and ESQL preprocessors is compiled in the usual way using the appropriate C compiler and linked with the appropriate routine libraries.

Linux: On Linux platforms, the gcc compiler is supported.

VMS: The DEC C compiler (sold by Hewlett-Packard) are supported on the OpenVMS platform.
Win: On Windows platforms, the C compiler identified by the cc symbol in the file .\dev\makefile.mak below the installation directory is supported.

Note: Other compilers, from other software distributors, may or may not be able to compile the MSQL and ESQL preprocessor output. Mimer Information Technology cannot guarantee the result of using a compiler that is not supported.

Linking

Linking the processed SQL module with a host application is done in the same way as user-written embedded C code, see [Linking Applications].

The SQL Compiler

At run-time, database management requests are passed to the SQL compiler responsible for implementing the SQL functions in the application program.

The SQL compiler performs two functions:

Note: Since all SQL statements are compiled at run-time, there can be no conflict between the state of the database at the times of compilation and execution. Moreover, the execution of SQL statements is always optimized with reference to the current state of the database.

Connecting to a Database

Connecting to a database is done much in the same way as in embedded programs, see Connecting to a Database. Every connect attempt is a separate SQL statement that needs its own module procedure.

Examples

Example SQL module:
 PROCEDURE connect_ident 
     :ident VARCHAR(100)
     :pswd VARCHAR(100)
     SQLSTATE;
 CONNECT TO 'the_database' USER :ident USING :pswd;
Example host application in C:
 // The character arrays are larger to make room for null termination.
 void connect_ident(char ident[101], char pswd[101], char sqlstate[6]);
 
 int main()
 {
     char sqlstate[6];
     char ident[101] = "SYSADM";
     char pswd[101] = "SYSADM";
 
     connect_ident(ident, pswd, &sqlcode);
Example host application in Fortran:
       CHARACTER*5 SQLSTATE
       CHARACTER*100 IDENT
       CHARACTER*100 PSWD
 
       IDENT = 'SYSADM'
       PSWD = 'SYSADM'
       CALL CONNECT_IDENT(IDENT, PSWD, SQLSTATE)
Example host application in Cobol:
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 SQLSTATE PIC X(5).
        01 IDENT PIC X(100).
        01 PSWD PIC X(100).
 
        PROCEDURE DIVISION.
        HEAD SECTION.
 
        MAIN.
 
            MOVE "SYSADM" TO IDENT.
            MOVE "SYSADM" TO PSWD.
 
            CALL "CONNECT_IDENT" USING IDENT, PSWD, SQLSTATE.
Example host application in Pascal:
 type chararray = packed array [1..100] of char;
 type sqlstatearray = packed array [1..5] of char;
 
 var
 sqlstate : sqlstatearray;
 ident : chararray;
 pswd : chararray;
 
 procedure connect_ident(var ident : chararray, var pswd : chararray,
    var sqlstate: sqlstatearray); external;
 
 begin
    ident := 'SYSADM';
    pswd := 'SYSADM';
    connect_ident(ident, pswd, sqlstate); 

Mimer
Mimer Information Technology AB
Phone: +46 18 780 92 00
info@mimer.com
Mimer SQL Documentation TOC PREV NEXT INDEX