2. Embedded SQL for C : C Variables and Data Types : Variable and Type Declarations : # Define Declaration
 
Share this page                  
# Define Declaration
The preprocessor accepts the # define directive, which defines a name to be a constant_value. The preprocessor accepts the constant_name when it is in an embedded SQL statement and treats it as if a constant_value had been given.
The syntax for the # define statement is:
# define constant_name constant_value
Note:   
The constant_value must be an integer, floating-point, or character string literal. It cannot be an expression or another name. It cannot be left blank, as happens if you intend to use it later with the # ifdef statement. If the value is a character string constant, you must use double quotes to delimit it. Do not delimit it with single quotes to make the constant_name be interpreted as a single character constant, because the preprocessor translates the single quotes into double quotes. For example, the preprocessor interprets both of the following names as string constants, even though the first might be intended as a character constant:
# define quitflag 'Q'
    # define errormsg "Fatal error occurred."
The preprocessor does not accept casts before constant_value. In general, the preprocessor does not accept casts, and it interprets data types from the literal value.
Do not terminate the statement with a semicolon.
You can only use a defined constant to assign values to Ingres objects. Attempting to retrieve Ingres values into a constant causes a preprocessor error as demonstrated in this example.
Example: Retrieving Ingres values into a constant
exec sql begin declare section;
# define MINEMPNUM 1
# define MAXSALARY 150000.00
# define DEFAULTNM "No-name"
exec sql end declare section;
Embedded SQL statements in the program can reference :constant_name.
Example: :constant_name usage
exec frs putform formname (salary= :MAXSALARY);