Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
Controlling Database Transactions : Database transactions in applications : Multi-database applications : Checking database connections
 
Checking database connections
If you want to test database connections prior to entering a database transaction, use the CONNECTED function:

sample7

IF CONNECTED("db1") AND CONNECTED("db2") THEN
  RUN txnblk.p. /* transaction block */
ELSE
  RUN HTML-Error IN web-utilities-hdl ("Unable to perform transaction").
Note: The txnblk.p procedure exists only for illustration.
You should connect to all databases affected by a database transaction prior to entering a transaction block. As a general rule, do not execute a database connection in a transaction block. The database connection overhead could lock records in other databases affected by the transaction for a considerable length of time. A database connection failure also causes a database transaction error. WebSpeed defers DISCONNECT statements in a database transaction until the transaction completes or is undone.
For more information about connecting and disconnecting databases, see the CONNECT and DISCONNECT statements in OpenEdge Development: ABL Reference.