Friday, March 18, 2005

TAL Stack Issues

In writing a TAL SQL program, a problem was encountered that was hard to resolve. The symptoms manifested themselves as an ABEND condition on a SQL statement. Since SQL statements are precompiled in the SQLCOMP step, the statement was known to be valid so another problem existed. Single stepping through the program using INSPECT, the program would ABEND with no error code when the SQL statement was executed. This made the program extremely difficult to debug until a TAL program was written that had only one SQL statement. By doing that, the SQL error code was obtained which led to the identification of the stack problem. There are several other ways to obtain the error condition. The SAVEABEND file contains the error number and the SQLCA area contains the stack overflow text associated with this problem; however finding this information is not trivial and requires some knowledge of the SQL area structures. In addition, an EMS log message is generated that contains a trap code of 03 (stack overflow).

In TAL, you need to define a stack large enough to hold the SQL statements. To solve the problem, use a stack size of 32 (the full lower half of the stack). We did not try to optimize the stack size, so it may be possible to run with a smaller stack size. This problem is unique to TAL programs; the COBOL and C compilers handle the stack sizing for you.

No comments: