NOTE C is a case-sensitive language. The names of objects declared in a C program are case sensitive, but the names of SQL tables and other names are not case sensitive. Therefore, you must be careful about C constructs that you specify in SQL statements. These constructs include variable names and labels of program sections. See the Oracle Rdb Guide to SQL Programming for more information about declaring C variables. The following list describes the variable declaration syntax for character data types that the SQL precompiler supports in C: o char x[n] o char *x, assumes LONG VARCHAR type (that is, char x[16383]) o char CHARACTER SET character-set-name clause The CHARACTER SET character-set-name clause is optional. o $SQL_VARCHAR (n) o $SQL_VARCHAR (n) CHARACTER SET character-set-name The CHARACTER SET clause is optional. For information about the supported character sets, see the Oracle Rdb SQL Reference Manual. The following list describes the variable declaration syntax that the SQL precompiler supports in C: o Data type keywords o Storage class identifiers and modifiers o struct o union o typedef o Initial value assignments o Arrays Only single-dimension arrays are supported and only to declare an indicator array for use with a reference to a structure in SQL statements. Furthermore, the size of the array must be specified explicitly. Although you can use any data type for indicator array elements, Oracle Rdb recommends that you use variables of the data type integer, such as int or short. o Pointers Only a single level of pointer variables are supported and only those that point to elementary data types. Because C pointer variables cannot specify length attributes, SQL sometimes must allocate the largest possible piece of memory to process statements that refer to char pointer variables. SQL cannot determine the length of char pointer variables and allocates 16,383 bytes of memory for each variable in the following cases: - The SQL statement contains a concatenated value expression or a substring. - The SQL statement refers to the char pointer variable in a predicate, such as WHERE EMP_ID = :POINTER_VAR. - The SQL statement converts the contents of the char pointer variable to a numeric data type in the database. Avoid the use of char pointer variables in these cases because such a large memory allocation for char pointer variables wastes memory and degrades performance, especially for remote database access. o Valid declaration syntax The following are examples of valid declaration syntax: a_var[10]; $SQL_VARCHAR(10) x,y,z; int SQLCODE; struct { char b_var[5]; short int c_var; } a_record; union { char string_date[17]; struct { char year_var1[2]; char year_var2[2]; char month_var[2]; char day_var[2]; char hour_var[2]; char minute_var[2]; char second_var[2]; char hundredth_var[2]; } date_group; } date_union; int indicator_item[2]; globaldef double c_var; static d_var; char *x; o Invalid declaration syntax Table 7 Supported C Datatypes C type or typedefSQL type Comments and Restrictions char CHARACTER char LONG VARCHAR Assumed to be VARCHAR (16383) * char CHARACTER n must be be an integer literal; [n] #define names or expressions are not supported. int INTEGER Cannot be specified as unsigned. short SMALLINT Cannot be specified as unsigned. short INTEGER Cannot be specified as unsigned. int long INTEGER Cannot be specified as unsigned. int float REAL double DOUBLE PRECISION enum INTEGER long INTEGER On OpenVMS the data type long is 32 bits int8 TINYINT Requires #include <ints.h> int16 SMALLINT Requires #include <ints.h> __int16SMALLINT int32 INTEGER Requires #include <ints.h> __int32INTEGER int64 BIGINT Requires #include <ints.h> __int64BIGINT $SQL_VARCHAR (n) The CHARACTER SET clause is optional. SQL_DATE The SQL precompiler will transform the SQL_DATE_ANSI pseudo types in natvie C datatypes SQL_DATE_VMS SQL_TIME SQL_TIMESTAMP SQL_INTERVAL (DAY Use this data type for variables that TO SECOND) represent the difference between two dates or times. Precompiler Date-Time Data Mapping lists all the supported INTERVAL data types.