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:
- Update data dictionary (Test only)
- Reorganize data (Test only)
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
-
Update data dictionary (Test only)
Checks whether the data dictionary matches the datafile structure. -
If no update is required, Reorganize data (Test only)
Checks whether a physical reorganisation would be required. -
The final value of
#Freflects the true state:kTruemeans a reorganisation is requiredkFalsemeans 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
- Extremely fast, even on large datafiles
- No field probing
- No runtime errors
- No unnecessary reorganisations
- Uses only supported Omnis Classic behaviour
Most importantly, it relies on the data manager, not guesswork in application code.
Summary
When working with Omnis Classic:
- Do not attempt to detect missing fields at runtime
- Do not reorganise blindly on startup
- Use Test only dictionary and reorganisation checks
- Let Classic tell you when a reorganisation is needed
This approach is safe, efficient, and consistent with how long-lived Omnis Classic systems are designed to operate.