Question

I'm running Apache on the IBM i, set up for CGI calls to RPG ILE programs that use embedded SQL.

I'm getting various SQL errors in these programs (eg "Indicator variable required" and "Cursor not open"), but I can't find which programs specifically are causing these issues. There are many hundreds of programs in this system, and hitting F1 on the error messages does not specify the source program (the message is from/to 'QSQRUN2').

I can't recompile every program in debug mode, which might give more information (production system, some source issues).

Any ideas on how to get this information?

Was it helpful?

Solution 3

@user2338816 gave this answer in the comments.

There is an easy way to add SQL monitoring for specific jobs.

STRDBMON OUTFILE(QGPL/DBMON) JOB(*ALL/QTMHHTTP/WEBSERVER) FTRSQLCODE(*NONZERO)

Starts a monitor that monitors all jobs (current or future) for user QTMHHTTP, job WEBSERVER, logging all statements that give a warning or error.

See here for details on the resulting QGPL/DBMON database file.

You can then cross reference the job number/time in the job log if you need some context.

OTHER TIPS

Where are seeing the errors?

You say "hitting F1..." do you mean hitting F10=Display Messages in Job Log; from the 7=Display message on the WRKACTJOB screen?

If so, try 5=Work With and 11=Display Call stack..

If the job's not going into MSGW, then your programs are swallowing the errors. Either improperly without doing anything with them. Or properly after handling the issue (and neglecting to clean up the job log) or logging the data you need somewhere. You'll just have to find out where.

Below is an example of the message in the job log, and it has a statement in the "Cause" that calls out the host variable name. In the example, it is "TCANDSBMDT". Does that help narrow it down?

Message ID . . . . . . :   SQL0305                                             
Date sent  . . . . . . :   08/06/12      Time sent  . . . . . . :   10:41:52   

Message . . . . :   Indicator variable required.                               

Cause . . . . . :   A FETCH, embedded SELECT, CALL, GET DESCRIPTOR, or a SET   
  or VALUES INTO statement has resulted in a null value, but an indicator      
  variable was not specified for host variable TCANDSBMDT. ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top