User Tools

Site Tools


null_return_null_file_field_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== NULL (return null file field) ====== Previous pageReturn to chapter overviewNext page

NewC7.jpg

NULL(field)

NULL(file, field)

blk2blue.jpg

NULL Determines null “value” of a field.
field The label (including prefix) of a field in a FILE structure. This may be a GROUP or RECORD structure.
file The label of a FILE.

The NULL procedure returns a non-zero value (true) if the field is null, and zero (false) if the field contains any known value (including blank or zero). If the field is a GROUP or RECORD structure, all component fields of the GROUP or RECORD must be null for NULL to return true.

(All SQL drivers)

NULL(datefield) and NULL(timefield) returns TRUE if they are part of a DATE/TIME group and the corresponding column on the server is NULL

Support for null “values” in a FILE is entirely dependent upon the file driver.

You can pass a file as the first parameter to NULL. This allows you to pass references to fields (see the example below).

Return Data Type: LONG

Example:

Customer FILE,DRIVER('MSSQL'),PRE(Cus)  !Declare customer file layout

AcctKey   KEY(Cus:AcctNumber)

Record     RECORD

AcctNumber  LONG

OrderNumber LONG

Name        STRING(20)

Addr        STRING(20)

CSZ         STRING(35)

          END

        END

Header  FILE,DRIVER('MSSQL'),PRE(Hea)  !Declare header file layout

AcctKey    KEY(Hea:AcctNumber)

Record     RECORD

AcctNumber  LONG

OrderNumber LONG

ShipToName  STRING(20)

ShipToAddr  STRING(20)

ShipToCSZ   STRING(35)

          END

       END

CODE

OPEN(Header)

OPEN(Customer)

SET(Hea:AcctKey)

LOOP

 NEXT(Header)

  IF ERRORCODE() THEN BREAK.

 IF NULL(Hea:ShipToName)         !Check for null ship-to address

  Cus:AcctNumber = Hea:AcctNumber

  GET(Customer,Cus:AcctKey)      !Get Customer record

   IF ERRORCODE()

    CLEAR(Cus:Record)

   END

  Hea:ShipToName = Cus:Name      ! and assign customer address

  Hea:ShipToAddr = Cus:Addr      ! as the ship-to address

  Hea:ShipToCSZ  = Cus:CSZ

 END

 PUT(Header)                     !Put Header record back

END

!Example Two ' Use of file parameter

SwapNullState PROCEDURE(File F, *? var)

 CODE

   IF NULL(f, var)

     SETNONULL(f, var)

   ELSE

     SETNULL(f, var)

   END

See Also:

SETNULL

SETNULLS

SETNONULL

GETNULLS

null_return_null_file_field_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1