Calling Oracle SQLGLM in 64-bit fails with RTS 114

Calling Oracle SQLGLM in 64-bit fails with RTS 114

Problem

With SQLCA's SQLERRMC limited to PIC X(70), calling Oracle's SQLGLM allows to retrieve error messages longer than 70 characters. The following works fine in 32-bit:

05 ORACLE-ERROR-TEXT         PIC X(100) VALUE SPACES.
05 ORACLE-ERROR-SIZE         PIC S9(9) COMP-5 VALUE 100.
05 ORACLE-MSG-LENGTH         PIC S9(9) COMP-5 VALUE ZERO.

CALL 'SQLGLM' USING ORACLE-ERROR-TEXT,
                    ORACLE-ERROR-SIZE,
                    ORACLE-MSG-LENGTH

However in 64-bit, the same CALL fails with RTS 114 'Attempt to access item beyond bounds of memory'.

Solution

The Oracle 64-bit version requires a 64-bit data definition for the length parameters passed to SQLGLM. They should be defined as PIC S9(18) COMP-5.

The following should work across both 32-bit and 64-bit platforms:

 05 ORACLE-ERROR-TEXT PIC X(100) VALUE SPACES.
$IF P64 SET
 05 ORACLE-ERROR-SIZE PIC S9(18) COMP-5 VALUE 100.
 05 ORACLE-MSG-LENGTH PIC S9(18) COMP-5 VALUE ZERO.
$ELSE
 05 ORACLE-ERROR-SIZE PIC S9(9) COMP-5 VALUE 100.
 05 ORACLE-MSG-LENGTH PIC S9(9) COMP-5 VALUE ZERO.
$END

Note: The above is also applicable to Net Express.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
3 of 3
Last update:
‎2020-04-17 16:45
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.