Connecting to a remote location from a procedure

The QMF CONNECT command lets you connect to a remote database.

You can use this command within a linear procedure or a procedure with logic, except when the procedure has been passed as a parameter on a CALL statement that starts QMF as a stored procedure.

In the following example, suppose that you are an administrator in Miami, and you want to write a procedure that:
  1. Connects to a remote location (DALLAS)
  2. Issues a series of QMF commands
  3. Prints a report
  4. Reconnects to the originating location (MIAMI)
The procedure looks like the one that is shown in the following figure.
Figure 1. This procedure uses the CONNECT command.
 
CONNECT TO DALLAS                          -- Connect to a database named DALLAS
RUN PROC GENERATE_REPORT (FORM=GEN_FORM    -- Issue QMF commands
PRINT REPORT                               -- Print report on printer whose name is specified in QMF profile
CONNECT TO MIAMI                           –- Connect to a database named MIAMI

Make sure that you store the procedure at the remote location in the same database to which you are connected when you issue the RUN PROC command. When you connect to a new location, QMF re-initializes your profile, except for the value of TRACE. It also re-initializes command synonyms and function keys to the values at the new (remote) location.

When you write procedures that use the QMF CONNECT command to access remote databases, keep the following guidelines in mind:
  • If you are connected to a remote database and issue a RUN PROC command, that procedure and all the objects used in that procedure must be stored at the remote database.
  • All QMF commands in the procedure run in QMF temporary storage at the system where QMF is running (the local system). However, all objects used by these QMF commands (such as queries, procedures, or forms) must be defined in the database at the remote location.
  • All commands that affect the database (for example, SQL statements, QMF queries, or EDIT TABLE updates) run at the remote location.
  • If the procedure contains system-specific commands (CICS® or TSO), these commands run at the system where QMF is running (the local system).

    If your procedures contain system-specific commands that cannot run on the system where QMF runs, your procedure will not run successfully.

  • Any files, data sets, or data queues that are used in a system-specific command must exist on the system where QMF is running (the local system).
  • If your site uses TSO and takes advantage of RACF® support for mixed-case passwords, ensure that the CASE option of your QMF profile is set to MIXED. Otherwise, QMF converts all input to upper case, causing the CONNECT command to fail. In this situation, ensure that you enter all input in upper case, because QMF only recognizes commands in upper case.