Contents | Prev | Next

7.2.31 The isnull function

Description

The isnull function returns a value of type boolean, which indicates whether the parameter passed to it is null. If the parameter is null then the value true is returned, and if the parameter is not null then the value false is returned. This function is usually used to test values retrieved from databases with recordset.field.

Parameter

The isnull function's only parameter is an expression of variant type.

Example

The following code fragment uses isnull to check the values of the last_name and first_name fields to see if they are null, and if so handle them specially.

   new(rs);
   rs.open(conn, 'select last_name, first_name from customer', rsforward);
   while not rs.eof
      begin
         if isnull(rs.field('last_name')) then
            write('NULL')
         else
            write(rs.field('last_name'));
         write(', ');
         if isnull(rs.field('first_name')) then
            writeln('NULL')
         else
            writeln(rs.field('first_name'))
         rs.movenext;
      end;
   rs.close;
   dispose(rs);

Portability

Operating Systems: All
Standard Pascal: No

Contents | Prev | Next