Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Database Access : Database connections : Connection failures and disruptions : Using the CONNECTED function
 
Using the CONNECTED function
The CONNECTED function tests whether a database is connected. This function helps you to route program control around portions of an application that might be affected by database connection failures and disruptions. This example tests a database connection with the CONNECTED function:
IF NOT CONNECTED(logical-name) THEN DO:
  MESSAGE "CONNECTING logical-name".
  CONNECT logical-name ... NO-ERROR.
END.
IF CONNECTED(logical-name) THEN
  RUN procedure.
ELSE
  MESSAGE "DATABASE NOT AVAILABLE".
If the database is not connected, the above code attempts to connect the database. This example only runs the procedure if the database is connected. Auto-connect precludes the use of the CONNECTED function to test for database connections. For more information on the CONNECTED function, see OpenEdge Development: ABL Reference.