I'd like to be able to imbed diagnostics capabilities into my programs so that I could use an environment variable to turn on and turn off the SET EXPLAIN command at will. How do I do that?
Before running the code set an environment variable want explain = "Y." Early in the code, after the connection to the database is made, include some code similar to this pseudocode:
retrieve the environment variable into wantenv if wantenv == "Y" EXEC SQL SET EXPLAIN ON; else EXEC SQL SET EXPLAIN OFF; done
If you use this technique, be sure that the environment variable is set to "N" by default in your environment, since the output files from SET EXPLAIN can grow very large very quickly.