5. Embedded QUEL : Host Language Variables : Indicator Variables : Setting Values Using Null Indicators
 
Share this page                  
Setting Values Using Null Indicators
To assign null to a database column, set the indicator variable (associated with the host variable you are writing) to -1 and execute the assignment statement. You can also assign null using the keyword null.
You can use the following statements in conjunction with indicator variables to assign null values:
append
replace
replace cursor
If you attempt to assign a null to an object that is not nullable, the DBMS Server issues a runtime error.
A null indicator variable can accompany a variable used in the where clause of the retrieve, append and replace statements, if you are comparing with nullable columns or expressions.
The following example demonstrates the use of both an indicator variable and the null constant: an indicator variable is used to set "phone" to null (if no phone number was entered), and the null constant is used to set the "comment" field before it is written to the new employee database.
read ename, eno, phone from terminal
if phone = "" then
  phone_null = -1
else
  phone_null = 0
end if
##append to newemp (empname = ename,
##  #phone = phone:phone_null,
##  empnum = eno, comment = null)