NULL XFD Directive

The NULL XFD directive allows the specification of a value which would indicate a field's contents are to be treated as NULL in interactions with the DBMS. It enables Acu4GL to handle NULL values by comparing values when performing read and write actions on the database to determine and perform appropriate actions. This directive is only valid with non-key fields.

Syntax

$XFD NULL=literal
where literal is any literal value, or one of the following special literals to indicate that the field is comprised entirely of a specific type of value:
  • LOW-VALUES
  • HIGH-VALUES
  • SPACES
  • ZEROES

Specify the NULL XFD directive on individual fields within the COBOL FD.

During a write to the database, this directive compares the value of the COBOL field against its own set literal value. If the values are equal, it writes a NULL value to the database.

During a read of the database, if a NULL value is returned, this directive places the specified literal value into the COBOL field before returning to the COBOL program.

Notes:
  • Fields allowing NULL values are not allowed as part of a record key. If the compiler encounters a record key containing NULL values, it returns a syntax error.
  • When using the NULL directive with the SPACES literal, the behavior for a numeric field when writing to the database or reading from the database is equivalent to the ZEROES literal.

Example

01	myRecord.
      $XFD NULL=”NULL”
           05 item1             pic x(8).
      $XFD NULL=ZEROES
           05 item2             pic 9(8).

When the item1 alphanumeric field is the string NULL when writing to the database, NULL is written to the corresponding cell in the database.

If the database returns NULL during a read operation, NULL is placed into item1

Similarly, if the numeric field item2 has value 0 when writing to the database, NULL will be written to the corresponding cell in the database.

If the database returns NULL during a read operation, 0 is places into item2.