The QCMDEXC SQL scalar function is one of my favorite SQL features. I have used it many times in my work, and here in articles on this website. As part of the latest Technology Refresh, IBM i 7.6 TR2 and 7.5 TR8, it is further enhanced by now being able to write the command performed to the job log.
QCMDEXC scalar function now has two parameters:
- COMMAND: The CL command to perform
- PRINT: Whether the CL command should be written to the job log. This can contain the following:
- ERROR: Only write to the job log if the command fails
- NONE: No command is written to the job log. This is the default
- VERBOSE: The command is always written to the job log
Before I start describing in details what this change does, I need to have something I can do using the QCMDEXC scalar function. In this scenario I have a DDL table, TESTTABLE, that contains a list of files that I want to delete using a Delete File command, DTLF, in this scalar function.
I can show the contents of this table with the following:
01 SELECT * FROM TESTTABLE |



