Use the ON CONNECT/PACK command to run a command file before connecting to or packing a database. The command can also be used to run a command file, code stored in a table, or stored procedure after connecting to or packing a database.

Options
AFTER
Indicates the command file should be run after the CONNECT/PACK.
BEFORE
Indicates the command file should be run before the CONNECT/PACK.
CALL procname
Indicates the stored procedure should be called after the CONNECT/PACK.
CONNECT
Indicates the command file should be run when connecting a database.
FIRST
Indicates the command file should be run on the first connect only.
PACK
Indicates the command file should be run when packing a database.
RESET
Clears out the ON CONNECT/PACK command recorded in the database.
RUN
Runs a command file or procedure stored within a table.
cmdfile
Specifies the name of the command file to execute.
SAVE
Specifies that the parameters in the cmdfile or from the RESET will be saved to the database. Any options without the SAVE parameter will only be active for the current session.
SELECT VARCHAR clause
Specifies a column defined with the VARCHAR data type from a table, from which you can run the contents. The SELECT clause must limit the data to only one row; otherwise, an error is returned.
USING parmlist
Lists the values the command file uses when it runs. The parameter list can contain up to 18 values. The first value in the list is referenced in the executed file as %1, the second as %2, and so on through %9. They are treated just like other variables. To reference the contents of these variables, preface the variable name with a dot (.); for example, set v1 =.%1.
About the ON CONNECT/PACK command
The ON CONNECT/PACK command is useful for running a specific command file whenever a database is connected or packed. A common use would be to run a command file that does an AUTOCHK command before connecting. The ABORT ON command could then be used to cause the CONNECT/PACK to be aborted after the command file finishes.
Examples:
Example 01:
-- Runs a routine in the CommonCode table when the database is first connected
ON FIRST CONNECT RUN SELECT CCData FROM CommonCode WHERE CCID = 29 SAVE
Example 02:
-- Runs the CheckDB.rmd command file before the database is packed
ON BEFORE PACK RUN CheckDB.rmd SAVE