SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

Simple and Compound Statements
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
5-7
Inserting a Date-Time Value
void blank_pad(char *buf, size_t size)
{
size_t i;
i = strlen(buf);
if (i < size)
memset(&buf[i], ' ', size - i);
buf[size] = '\0';
} /* end blank_pad */
Example
This statement uses the NULL keyword instead of an indicator variable:
EXEC SQL INSERT INTO persnl.employee
VALUES (:emp.empnum, :emp.first_name,
:emp.last_name, :emp.deptnum, :emp.jobcode,
NULL);
Example
This example inserts a row into the EMPLOYEE table and sets the SALARY column to
null by using an indicator variable:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
* Declare host variables EMPNUM, FIRST-NAME,
* LAST-NAME, DEPTNUM, JOBCODE, and SALARY.
...
01 IND-1 PIC S9(4) COMP.
EXEC SQL END DECLARE SECTION END-EXEC.
...
PROCEDURE DIVISION.
...
MOVE -1 TO IND-1.
* Move values to host variables EMPNUM, FIRST-NAME,
* LAST-NAME, DEPTNUM, JOBCODE, and SALARY.
...
EXEC SQL INSERT INTO persnl.employee
VALUES (:EMPNUM, :FIRST-NAME, :LAST-NAME,
:DEPTNUM,:JOBCODE,
:SALARY INDICATOR :IND-1)
END-EXEC.
Example
This example uses the NULL keyword instead of an indicator variable:
EXEC SQL INSERT INTO PERSNL.EMPLOYEE
VALUES (:EMPNUM, :FIRST-NAME, :LAST-NAME,
:DEPTNUM,:JOBCODE, NULL)
END-EXEC.
Inserting a Date-Time Value
For standard date-time columns (DATE, TIME, or TIMESTAMP, or the SQL/MP
DATETIME equivalents), you insert a row directly with the date-time host variable. For
C
COBOL
COBOL