SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)

C/C++ Program Compilation
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL663854-005
15-10
Preprocessor Functions
The following is the content of the generated module file:
ALLOCATE STATIC INPUT DESCRIPTOR
SQLMX_DEFAULT_STATEMENT_1_0_IVAR FOR STATEMENT
SQLMX_DEFAULT_STATEMENT_1 (CHARACTER(20) NOT NULL);
--------- STATEMENT INDEX 0 ---------
PROCEDURE SQLMX_DEFAULT_STATEMENT_1 ("a" CHARACTER(20)) INSERT
INTO t1 (val) values(:"a");
The pragma, #pragma SQL CHAR_AS_STRING – SQL/MX Release 3.1, supports the
CHAR_AS_STRING pragma in the embedded SQL file. The length of all character
descriptors will be one byte less than that defined in the application. This is the default
behavior.
The pragma can be placed anywhere in the file. However, the pragma will be effective
from one definition until the next, or until the end of file.
The following example uses the pragma SQL CHAR_AS_STRING:
#pragma SQL CHAR_AS_STRING
EXEC SQL BEGIN DECLARE SECTION;
char a[20];
EXEC SQL END DECLARE SECTION;
---
strcpy(a,"ramu");
EXEC SQL INSERT INTO t1 (val) values(:a);
The following is the content of the generated module file:
ALLOCATE STATIC INPUT DESCRIPTOR
SQLMX_DEFAULT_STATEMENT_1_0_IVAR FOR STATEMENT
SQLMX_DEFAULT_STATEMENT_1 (CHARACTER(19) NOT NULL);
--------- STATEMENT INDEX 0 ---------
PROCEDURE SQLMX_DEFAULT_STATEMENT_1 ("a" CHARACTER(19)) INSERT
INTO t1 (val) values(:"a");
C #include directive
The preprocessor expands first-level #include files. The original #include line is
commented in the output source file. The commented line is followed by the #include
file contents.
Note. INVOKE includes its own option to support CHAR_AS_ARRAY and CHAR_AS_STRING.
When the pragma is defined at the file level and the INVOKE option is not defined, the pragma
definition is considered. However, when the pragma and the INVOKE option are defined, the
INVOKE option will override the pragma definition.