Progress
Language Reference


CONNECT Statement

Interfaces
OS
SpeedScript
All
All
Yes

Allows access to one or more databases from within a Progress procedure.

SYNTAX

CONNECT
  { { physical-name | VALUE ( expression ) } [ options ]
     |  options
  }
  [ NO-ERROR ] 

physical-name

The actual name of the database on disk. It can be a simple filename, relative pathname, or a fully qualified pathname, represented as an unquoted string, a quoted string, or a VALUE ( expression ). If you do not give a fully qualified pathname, Progress searches for the database relative to your current directory.

VALUE ( expression )

An expression (a constant, field name, variable name, or expression) whose value is a string representing the physical name of a database to connect.

options

One or more options, similar to those used to start Progress. Valid options are a subset of Progress startup parameters. Note that parameters are case sensitive.

See the Progress Startup Command and Parameter Reference for more information on Progress parameters.

NO-ERROR

Suppresses errors in the act of connecting. This does not mean that all errors produced by the server are suppressed; only errors caused by the CONNECT statement itself. For example, if the server to which you are connecting runs out of resources, its error message will not be suppressed. If a CONNECT error occurs (for example, the database does not exist or is in use in single-user mode), error information is written to the ERROR-STATUS system handle.

You also can use the CONNECTED function to determine whether the CONNECT succeeded and then retrieve error messages from the ERROR-STATUS handle.

EXAMPLES

This procedure attempts to connect to databases mydb1 and mydb2 in single-user mode, with error suppression. You must connect to a database before you run a procedure that references it.

r-connct.p
CONNECT mydb1 -1 -db mydb2 -1 NO-ERROR. 

In the next example, assume database sports has not been previously connected, so the following r-cnct1.p procedure fails. At the start of execution, r-cnct1.p checks whether sports is connected. If sports is not connected, a run-time error occurs. As shown in the example, attempting to connect to sports within the procedure does not solve the problem.

/* NOTE: this code does NOT work */

CONNECT sports -1.
FOR EACH sports.customer:
  DISPLAY customer.
END. 

Instead, split r-cnct1.p into two procedures, as shown in r-cnct2.p and r-dispcu.p.

r-dispcu.p
FOR EACH sports.customer:
    DISPLAY customer.
END. 

r-cnct2.p
CONNECT sports -1.
RUN "r-dispcu.p". 

This time, database sports is connected before r-dispcu.p is invoked, so r-dispcu.p runs successfully.

NOTES

SEE ALSO

ALIAS Function, CONNECTED Function, CREATE ALIAS Statement, CREATE DATABASE Statement, DATASERVERS Function, DBCODEPAGE Function, DBCOLLATION Function, DBRESTRICTIONS Function, DBTYPE Function, DBVERSION Function, DELETE ALIAS Statement, DISCONNECT Statement, FRAME-DB Function, LDBNAME Function, NUM-DBS Function, PDBNAME Function, SDBNAME Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095