Anyone who develops IBM i applications knows the QTEMP library very well, the temporary library that the system automatically creates and destroys for each job. But it cannot always be used; for example, the RTVDIRINF (Retrieve Directory Information) command does not accept the QTEMP library; or, in certain particular applications there is a need to create temporary objects which however must be shared with other applications. It can therefore be useful to have alternatives to QTEMP. Let’s see some of them.
The /tmp directory is a directory that can be used to create temporary stream files. If you decide to use /tmp it is important to know that the Unix clrtmp utility cleans the /tmp directory by deleting all the files present. On other systems, the /tmp directory is cleaned up every time the system is started; in IBM i, the /tmp directory is not cleaned at system startup, so you must run the ‘QSH CMD (clrtmp)’ command in the launcher specified by the QSTRUPPGM system value to clean the /tmp directory immediately after IPL, the only time when we are sure that no files are used. Before creating files in the /tmp directory, you need to think of a method to prevent jobs from treading on each other; a good solution is to create the files in a sub directory with the qualified name of the job, for example ‘/tmp/[job-user]/[job-name]/[job-number]’ taking care to delete it at the end of the job with the RMVDIR command (Remove directory) because, unlike the QTEMP library, the /tmp directory is not work related, so know that the files created in /tmp are available to all users with adequate authorization.
Like the /tmp directory, it may be convenient to create a temporary scheme for each job in which to create temporary objects. Also in this case the qualified name of the job helps us to have a good uniqueness, therefore we can create the schema with the SQL statement ‘CREATE SCHEMA xxxxx_[job-user]_[job-name]_[job-number]’ where xxxxx is a prefix dedicated to these schema, to which the system automatically assigns the name library ‘xxxxxnnnnn’ where nnnnn is a progressive from 00001 to 99999 managed by the system. The name of the library can be easily found with the SQL statement ‘GET DIAGNOSTICS CONDITION 1 :[host-variable] = MESSAGE_TEXT’ executed after the creation of the schema, which returns the message ‘Schema xxxxxnnnnn created’. At the end of the work it is a good rule to cancel the scheme with the ‘DROP SCHEMA’ instruction to avoid the risk of exceeding 99999 libraries and in the QSTRUPPGM program enter the command ‘DLTOBJ OBJ (QSYS/xxxxx*) OBJTYPE (*LIB)’ .
Early April saw the release of the "Spring Version" of ACS Access Client Solution, version 1.1.9.5 Interesting new features especially…
If the packed agenda of sessions at Common Europe Congress 2024, June 3-6 Milan, wasn't enough for you, here's another…
Debugging functions with Visual Studio Code have been available for some time but this new version 2.10.0 simplifies the handling…
Two and a half years after my post Transferring objects with ObjectConnect and Enterprise Extender, I finally got around to…
With a little trick even a simple SELECT statement can execute any system command! Let's see how to do that...
A mini-serial guide to configuring, managing, using, and troubleshooting the IBM i NetServer