The SQL preprocessor

The SQL preprocessor is an executable named sqlpp.

The preprocessor command line is as follows:

sqlpp [ options ] sql-filename [ output-filename ]

The preprocessor translates the embedded SQL statements in a C or C++ source file into C code and places the result in an output file. A C or C++ compiler is then used to process the output file. The normal extension for source programs with embedded SQL is .sqc. The default output file name is the sql-filename with an extension of .c. If the sql-filename has a .c extension, then the default output file name extension will change to .cc.

Note

When an application is rebuilt to use a new major version of the database interface library, the embedded SQL files must be preprocessed with the same version's SQL preprocessor.

The following table describes the preprocessor options.

Option Description
-d Generate code that reduces data space size. Data structures are reused and initialized at execution time before use. This increases code size.
-e level

Flag as an error any static embedded SQL that is not part of a specified standard. The level value indicates the standard to use. For example, sqlpp -e c03 ... flags any syntax that is not part of the core SQL/2008 standard. The supported level values are:

  • c08   Flag syntax that is not core SQL/2008 syntax

  • p08   Flag syntax that is not full SQL/2008 syntax

  • c03   Flag syntax that is not core SQL/2003 syntax

  • p03   Flag syntax that is not full SQL/2003 syntax

  • c99   Flag syntax that is not core SQL/1999 syntax

  • p99   Flag syntax that is not full SQL/1999 syntax

  • e92   Flag syntax that is not entry-level SQL/1992 syntax

  • i92   Flag syntax that is not intermediate-level SQL/1992 syntax

  • f92   Flag syntax that is not full-SQL/1992 syntax

  • t   Flag non-standard host variable types

  • u   Flag syntax that is not supported by UltraLite

For compatibility with previous SQL Anywhere versions, you can also specify e, i, and f, which correspond to e92, i92, and f92, respectively.

-h width Limit the maximum length of lines output by sqlpp to width. The continuation character is a backslash (\) and the minimum value of width is 10.
-k Notify the preprocessor that the program to be compiled includes a user declaration of SQLCODE. The definition must be of type long, but does not need to be in a declaration section.
-m mode

Specify the cursor updatability mode if it is not specified explicitly in the embedded SQL application. The mode can be one of:

  • HISTORICAL   In previous versions, embedded SQL cursors defaulted to either FOR UPDATE or READ ONLY (depending on the query and the ansi_update_constraints option value). Explicit cursor updatability was specified on DECLARE CURSOR. Use this option to preserve this behavior.

  • READONLY   Embedded SQL cursors default to READ ONLY. Explicit cursor updatability is specified on PREPARE. This is the default behavior. READ ONLY cursors can result in improved performance.

-n Generate line number information in the C file. This consists of #line directives in the appropriate places in the generated C code. If the compiler that you are using supports the #line directive, this option makes the compiler report errors on line numbers in the SQC file (the one with the embedded SQL) as opposed to reporting errors on line numbers in the C file generated by the SQL preprocessor. Also, the #line directives are used indirectly by the source level debugger so that you can debug while viewing the SQC source file.
-o operating-system

Specify the target operating system. The supported operating systems are:

  • WINDOWS   Microsoft Windows, including Windows Mobile.

  • UNIX   Use this option if you are creating a 32-bit Unix application.

  • UNIX64   Use this option if you are creating a 64-bit Unix application.

-q Quiet mode—do not print messages.

-r-

Generate non-reentrant code.
-s len Set the maximum size string that the preprocessor puts into the C file. Strings longer than this value are initialized using a list of characters ('a','b','c', and so on). Most C compilers have a limit on the size of string literal they can handle. This option is used to set that upper limit. The default value is 500.
-u Generate code for UltraLite.
-w level

Flag as a warning any static embedded SQL that is not part of a specified standard. The level value indicates the standard to use. For example, sqlpp -w c08 ... flags any SQL syntax that is not part of the core SQL/2008 syntax. The supported level values are:

  • c08   Flag syntax that is not core SQL/2008 syntax

  • p08   Flag syntax that is not full SQL/2008 syntax

  • c03   Flag syntax that is not core SQL/2003 syntax

  • p03   Flag syntax that is not full SQL/2003 syntax

  • c99   Flag syntax that is not core SQL/1999 syntax

  • p99   Flag syntax that is not full SQL/1999 syntax

  • e92   Flag syntax that is not entry-level SQL/1992 syntax

  • i92   Flag syntax that is not intermediate-level SQL/1992 syntax

  • f92   Flag syntax that is not full-SQL/1992 syntax

  • t   Flag non-standard host variable types

  • u   Flag syntax that is not supported by UltraLite

For compatibility with previous SQL Anywhere versions, you can also specify e, i, and f, which correspond to e92, i92, and f92, respectively.

-x Change multibyte strings to escape sequences so that they can pass through compilers.
-z cs

Specify the collation sequence. For a list of recommended collation sequences, run dbinit -l at a command prompt.

The collation sequence is used to help the preprocessor understand the characters used in the source code of the program, for example, in identifying alphabetic characters suitable for use in identifiers. If -z is not specified, the preprocessor attempts to determine a reasonable collation to use based on the operating system and the SALANG and SACHARSET environment variables.

sql-filename A C or C++ program containing embedded SQL to be processed.
output-filename The C language source file created by the SQL preprocessor.
 See also