Calling Oracle SQLGLM in 64-bit fails with RTS 114

0 Likes
over 1 year ago

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.

Comment List
Anonymous
Related Discussions
Recommended