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 COBOL—523627-004
5-6
Inserting Null
Example
 EXEC SQL BEGIN DECLARE SECTION END-EXEC.
 01 JOB.
 02 HV-JOBCODE PIC 9(4) COMP.
 02 HV-JOBDESC PIC X(18).
 01 SQLSTATE PIC X(5).
 EXEC SQL END DECLARE SECTION END-EXEC.
 ...
 PROCEDURE DIVISION. 
 ... 
* Move values to HV-JOBCODE and HV-JOBDESC. 
 ... 
 EXEC SQL INSERT INTO persnl.job (jobcode, jobdesc)
 VALUES (:HV-JOBCODE, :HV-JOBDESC) 
 END-EXEC. 
 ... 
Inserting Null
You can insert a row of data with a null column.
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;
 char SQLSTATE[6];
 struct emp_tbl { 
 unsigned NUMERIC (4) empnum;
 char first_name[16];
 char last_name[21];
 ...
 } emp;
 short ind_1 = -1;
 ...
EXEC SQL END DECLARE SECTION;
...
/* Enter the values for employee */
printf("\nEnter employee number: ");
scanf("%hu", &emp.empnum);
printf("\nEnter first name: ");
scanf("%s", emp.first_name); 
...
blank_pad(emp.first_name, sizeof(emp.first_name) - 1);
blank_pad(emp.last_name, sizeof(emp.last_name) - 1);
EXEC SQL INSERT INTO persnl.employee 
 VALUES (:emp.empnum, :emp.first_name,
 :emp.last_name, :emp.deptnum, :emp.jobcode,
 :emp.salary INDICATOR :ind_1);
...
return 0;
} /* end main */
COBOL
C










