Checking Whether a Datafile Needs Reorganisation (Omnis Classic)

In Omnis Classic, detecting whether a datafile needs reorganisation after a schema change is not as simple as checking whether a field exists.

Classic does not provide runtime error trapping, schema introspection, or safe field-existence checks. Attempting to probe missing fields can result in hard runtime errors, and performing a full reorganisation on every startup is impractical for large datafiles.

The correct solution is to ask Omnis Classic itself whether the data dictionary and datafile are in sync.

The Key Insight

Omnis Classic already knows whether a reorganisation is required.
The trick is to ask it without actually doing the work.

Classic provides two operations that can be run in Test only mode:

These perform fast, metadata-level checks and return a Boolean result in #F, without touching the datafile.

Practical Solution

The following pattern reliably determines whether a reorganisation is required, without probing fields or rebuilding data:

;  
Update data dictionary (Test only)
Calculate LB_Needs_Update as #F

If not(LB_Needs_Update)
  Reorganize data (Test only)
  Calculate LB_Needs_Update as #F
End If
;  
Calculate #F as LB_Needs_Update
Quit procedure
;  
Local variable LB_Needs_Update (Boolean) = kFalse

How This Works

  1. Update data dictionary (Test only)
    Checks whether the data dictionary matches the datafile structure.

  2. If no update is required, Reorganize data (Test only)
    Checks whether a physical reorganisation would be required.

  3. The final value of #F reflects the true state:

    • kTrue means a reorganisation is required
    • kFalse means the datafile is already up to date

No data is modified, no records are touched, and no runtime errors can occur.

Why This Is the Right Approach

Most importantly, it relies on the data manager, not guesswork in application code.

Summary

When working with Omnis Classic:

This approach is safe, efficient, and consistent with how long-lived Omnis Classic systems are designed to operate.