Search code examples
ibm-midrangedb2-400rpgleembedded-sql

How do you make an RPGLE program write SQL warnings and errors to the job log?


It seems like I remember writing an RPG program that used embedded SQL that wrote a message to the interactive user job log whenever a SQL warning or error occurred. I did not have to explicitly write it; it logged it by default.

The program i am writing now is not doing this logging although I know I can cause warnings like 01003 and errors like 02000 and read them with the SQLState variable.

I don't think I imagined this behavior. Is there a H spec keyword that I forgot to set, the way I am calling the program (using CALL interactive), the way I wrote the SELECT INTO statement (static as opposed to dynamic)? I am at a loss for other ideas.


Solution

  • SqlStates 00000, 01###, and 02### do not produce logs though other states do. I would explicitly write anything to the log that you want to see there. You can easily write a sub-procedure that you can call after each sql statement to do the logging.