Errors with COMP host variables after compiling on Windows and running on Unix
When SQL programs contain host variables that are declared as COMP, compiling with OpenESQL on Windows and moving the INT code to a non-Intel platform gives incorrect values in the COMP variables.
Database applications that use COMP host variables and are compiled with OpenESQL, can only be used on platforms with the same native byte ordering.
This is because the OpenESQL pre-compiler inserts additional code for COMP host variables on Intel (little-endian) platforms to handle the reverse byte ordering of COMP, compared to the native byte ordering.
Thus when you transfer the compiled code to a non-Intel (big-endian) system such as AIX, the additional code for handling COMP causes byte swapping problems.
There are two solutions to the problem:
- Use COMP-5 instead of COMP for host variables. This has the added advantage of being more efficient compared to COMP.
- Recompile the source on the target platform, as the OpenESQL pre-compiler will not insert the additional code for handling COMP's on non-Intel platforms.