If you want to process null values in an embedded SQL statement in RPG you need to pass an additional indicator variable for each host variable. The indicator variable must be written after the host variable separated by a space. The indicator variable is no boolean field of type
N. It has to be of the SQL type SMALLINT which corresponds to the RPG type
5I 0 (or int(5) ) according to the IBM Information Center.
If the SQL statements returns a valid value in the host variable the indicator variable has the value of
0. If the host variable contains a null value the indicator variable has a value of
If a data structure is used as a host variable then an array of indicator variables must be passed after the host variable. The array needs the number of indicator variable as the number of fields in the data structure.
See IBM Redbook SQL for iSeries auf Seite 112 (Version V5R3 August 2005) chapter 2 - Language elements # References to variables # References to host variables.