In QMF it is possible to make your own commands. I have always been tired of writing RESET QUERY each time I want to clear the old query and type in a new one. It is much easier to use a command like RQ instead. You are able to create such a command and it is relatively easy.
If you are a QMF administrator or systems programmer you may create commands for all users of QMF which are instantly available by inserting data into the Q.COMMAND_SYNONYMS table. If you are an ordinary user you may create commands available for you only. this is what this tip is about. I will assume that your QMF session is started using your userid as both CURRENT SQLID and USER. The description may not work if CURRENT SQLID is not equal to USER.
First step is to create your private command table. The easiest way is to execute the QMF query CREATE TABLE QMF_COMMANDS LIKE Q.COMMAND_SYNONYMS. If this query fails you should try QMF command DI Q.COMMAND_SYNONYMS and then the QMF command SAVE DATA AS QMF_COMMANDS. The last approach will give you a table with the same contens as the global command table while the CREATE TABLE query will give you an empty table (if it works).
The next step is to activate your private command table. Please issue QMF query UPDATE Q.PROFILES SET SYNONYMS='QMF_COMMANDS' WHERE CREATOR = USER and then leave QMF and start up again. This is necessary because the command table is loaded into memory at start up of QMF. Therefore the UPDATE will not give the expected result at once. If you receive a SQL authorisation failure when you run the UPDATE you are unfortunately not able to create your own QMF commands. If you receive a SQL code of 100 then issue QMF command DI PROFILE followed by SAVE PROFILE. Maybe you have to change one of the parameters in the profile before you will have a private PROFILE. When the SAVE PROFILE works you should issue the UPDATE query again.
At this point I hope you have established and activated your own private command table. This is not funny unless you create some of your own commands. Please issue the following QMF query:
The column VERB must be set to the name of the command. Column OBJECT may contain the name of a parameter for the command. Column SYNONYM_DEFINITION must contain the QMF command to be executed when your private QMF command matches the contens of column VERB and perhaps column OBJECT. Unfortunately QMF only accepts the QMF commands RUN and TSO in column SYNONYM_DEFINITION. To make the above example work you have to create a QMF PROC called RQ. Please notice that you are able to execute REXX programs by filling out SYNONYM_DEFINITION with commands like TSO %MYREXX. When you have INSERT'ed your commands you must remember to leave and re-enter QMF in order to activate them.
The last thing to do is to create the QMF procedure RQ. Please issue QMF command RESET PROC and type in the following text as your QMF PROC:
After entering this text you must execute QMF command SAVE PROC AS RQ. If you do not type in the MESSAGE line QMF will reply to the RQ command with a "OK, your procedure was run" which is quite boring and not very informative. You are now able to execute RQ as a QMF command, at last. If it still does not work please exit QMF and re-enter. If it still does not work it is probably because CURRENT SQLID and USER has different values. You may find out by executing the QMF query SELECT CURRENT SQLID, USER FROM SYSIBM.SYSDUMMY1.
When you have succeeded in making the above work it is up to your fantasy to create new powerful QMF commands. I use EQ for EDIT QUERY and X for EXIT. You may have other needs so just go for it. If you work on an MVS installation with many different DB2 subsystems you will have to repeat this tip on each subsystem.