The BOOLEAN data type
uses the boolean data type to support the SQL BOOLEAN data type.
For a complete description of the SQL BOOLEAN data type, see the HCL OneDB™ Guide to SQL: Reference. This section describes how to manipulate the boolean data type.
EXEC SQL BEGIN DECLARE SECTION;
boolean flag;
EXEC SQL BEGIN DECLARE SECTION;
- TRUE
- '\1'
- FALSE
- '\0'
- NULL
- Use the rsetnull() function with the CBOOLTYPE as the first argument
If you want to assign the character representations of
'T
' or 'F
' to a BOOLEAN column,
you must declare a fixchar host variable and initialize it
to the desired character value. Use this host variable in an SQL statement
such as the INSERT or UPDATE statement. The database server converts
the fixchar value to the appropriate BOOLEAN value.
EXEC SQL BEGIN DECLARE SECTION;
boolean flag;
fixchar my_boolflag;
int id;
EXEC SQL END DECLARE SECTION;
id = 1;
flag = '\0'; /* valid boolean assignment to FALSE */
EXEC SQL insert into table2 values (:id, :flag); /* inserts FALSE */
id = 2;
rsetnull(CBOOLTYPE, (char *) &flag); /* valid BOOLEAN assignment
* to NULL */
EXEC SQL insert into table2 values (:id, :flag); /* inserts NULL */
id = 3;
my_boolflag = 'T' /* valid character assignment to TRUE */
EXEC SQL insert into table2 values (:id, :my_boolflag); /* inserts TRUE
*/