The CONNECT statement allows you to connect to a database from an ABL procedure or directly from the Procedure Editor. The CONNECT statement has the following syntax:
An argument that represents the actual name of the database on a disk. The first physical–name argument you specify in a CONNECT statement does not require the Database Name (–db) parameter. All subsequent physical–names must be preceded by the –db parameter.
parameter-file
The name of a parameter file that contains database connection information. See OpenEdge Deployment: Startup Command and Parameter Reference for more information on parameter files.
parameters
One or more database connection parameters. Each connection parameter applies to the most recently specified database (–db). For the parameters you can specify, see the information on client connection parameters in the OpenEdge Deployment: Startup Command and Parameter Reference.
NO-ERROR
This argument suppresses the error condition, but still displays the error message when an attempt to CONNECT to a database fails.
Although you can connect to several databases within one CONNECT statement, it is a good idea to connect only one database per CONNECT statement, because a connection failure for one database causes a termination of the current CONNECT statement. However, databases already connected when the statement terminates stay connected. In cases like this, it is a good idea to use the CONNECTED functions to see which databases were connected and which were not.
Here is an example of using a parameter file with the CONNECT statement:
CONNECT -pf parm3.pf.
In this example, the CONNECT statement uses the parm3.pf file to connect to the appldb1 database.
parm3.pf
-db appldb1
A single procedure cannot connect to and then access a database. The following code fragment does not run:
/* NOTE: this code does NOT work */
CONNECT sports2000.
FOR EACH sports2000.Customer NO-LOCK:
DISPLAY Customer.
END.
By splitting this example into a procedure and a subprocedure, you can connect to the database in the main procedure, and then access it in the subprocedure. For example:
i-topproc.p
CONNECT sports2000.
RUN i-subproc.p.
i-subproc.p
FOR EACH sports2000.Customer NO-LOCK:
DISPLAY Customer.
END.
For more information on the CONNECT statement, see OpenEdge Development: ABL Reference.