Nonstop Database, HiRDB Version 9 UAP Development Guide
The preprocessor features an option that allows you to use preprocessor declaration statements of the C compiler.
By specifying the -E option, you can execute the following functions with the preprocessor:
Assume that the following embedded variable declaration is specified in a UAP source file:
#include "user.h" EXEC SQL BEGIN DECLARE SECTION; char xchar1[MAX_CHAR_LEN]; EXEC SQL END DECLARE SECTION;
Also assume that the following literal is defined in the header file (user.h) that the UAP has included:
#define MAX_CHAR_LEN 256
In this case, the preprocessor reads the include file and uses the MAX_CHAR_LEN definition value to convert the embedded variable declaration to char xchar1[256]; before analyzing the UAP source file. However, macro literals cannot be used between the SQL prefix and the SQL terminator (in SQL statements).
Specify the directory path for include file retrieval as an option argument. The default directory of the C compiler does not need to be specified.
You can use the #ifdef statement to select the SQL statement to be preprocessed. An example is shown as follows.
#ifdef DEF_SWITCH EXEC SQL DECLARE CUR1 CURSOR FOR SELECT * FROM TABLE1; #else EXEC SQL DECLARE CUR1 CURSOR FOR SELECT * FROM TABLE2; #endif
However, preprocessor declaration statements of the C compiler cannot be specified between the SQL prefix and SQL terminator (in SQL statements).
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.