Contents


Migration Notes


Including Informix ESQL/C header files

For migration purposes, include statements for Informix ESQL/C header files are permitted, although they are not required and the FESQLC compiler will ignore them. However, if your program has such statements, you must use the EXEC SQL syntax. The following C syntax is not supported: 

#include "sqlca.h"

FESQLC will consider this a normal C header file to be included. The statement must be replaced by: 

EXEC SQL include sqlca;

Using C-style macros for ESQL/C host variables

Old Informix ESQL/C compilers allowed to use C-style macros in the declaration of host variables: 

#define MAXLEN 15

$char myvar[MAXLEN];

This is not standard ESQL/C programming. Recent Informix ESQL/C compilers raise now a warning in such case:

Warning -33208: Runtime error is possible because size of 'myvar' is unknown.

FESQLC does not support the usage of C-style macros in SQL host variables declarations. You must use ESQL/C macros instead:

EXEC SQL define MAXLEN 15;

$char myvar[MAXLEN];

Existing code using C-style macros may use the C macro in normal C variable declarations. Is such case you can define the macro twice: Once for the C variables and once for the ESQL/C host variables:

#define MAXLEN 15
EXEC SQL define MAXLEN 15;

char myvar1[MAXLEN];
$char myvar2[MAXLEN];

This solution is valid ESQL/C programming. It works with both Informix ESQL/C and Genero FESQLC compilers.


Using char and varchar pointers

Normally you use char/varchar arrays to hold SQL CHAR or VARCHAR data:

$char cn[101];
$SELECT cust_name INTO $cn FROM customer ... ;

Informix ESQL/C also supports char/varchar pointers, but the length of the C variable is unknown.

$char *cn;
$SELECT cust_name INTO $cn FROM customer ... ;

The char/varchar pointers are typically used for function parameters:

int func(p1, p2)
EXEC SQL BEGIN DECLARE SECTION;
int p1;
char *p2;
EXEC SQL BEGIN DECLARE SECTION;
{
EXEC SQL INSERT INTO tab VALUES ( :p1, :p2 );
}

or as constants:

$const char *blank = " ";
$const char *undef = "Undefined value";

Database APIs must know the size of the SQL char/varchar type corresponding to the host variable, to check for overflow. (For example, you cannot insert a CHAR(100) value into a CHAR(9) in Oracle).

Char and varchar pointers can be used as input parameters in SQL statements, but the FESQLC API computes the size with an strlen() of the current value pointed by sqlvar->sqldata.

It is strongly recommended that you use a fixed size of char and varchars. If you MUST use a char/varchar pointer, use an sqlda structure and specify the exact size of the corresponding CHAR/VARCHAR SQL type in sqlvar->sqllen.

Host variables defined as char or varchar pointers cannot be used to fetch data:

$char *c;
$varchar *v;
$select c1, c2 into :c, :v from t;

Database and database object names

EXEC SQL DATABASE supports only a simple database name; for portability the Informix database specification dbname@server is not supported.

The database prefix in a table name specification (dbname:tabname) is not supported, for portability.

Using SQL keywords as database object names is not supported.


Decimal host variables

Decimal host variables must be declared with precision and scale if you want to use a database other than Informix:

$decimal(6,2) mydec;

In an sqlda structure, sqlvar elements defining a DECIMAL value must have the sqllen member initialized with the decimal dimension (i.e., PRECMAKE(precision,scale). This is different from Informix ESQL/C, where sqllen has the size of the dec_t structure for input parameters.


Literal constants in USING clause

Literal constants are not allowed in a USING clause:

OPEN cursor USING 123, "abc" 

You must always use host variables.


Comment Indicator

The double hyphen (--) comment identifier is permitted within an SQL statement only. 

$SELECT * -- all columns       compiles successfully
    FROM tab;
$SELECT * FROM tab;
    -- all columns              will not compile

Features Not Supported