Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Database Access : Multi-database programming techniques : Positioning database references in an application
 
Positioning database references in an application
If possible, isolate database references within your application to help minimize the effects of a database connection failure on your application. This allows you to use the CONNECTED function effectively to test for a particular database connection, prior to passing program control to a subprocedure that accesses that database.
Figure 9. Positioning database references
The above figure shows a main procedure that connects two databases and runs subprocedures, depending on whether or not a database is connected. If the CONNECT statement in mainproc.p fails to connect db2, only db2proc.p subprocedure is effected by the database connection failure. This technique is useful for applications that run subprocedures from a menu.
Do not reference a database in your application startup procedure, except possibly to connect it. Remember, you cannot connect to a database and reference a database in the same procedure. If you reference a database on an auto-connect list within the startup procedure of your application and the auto-connect fails for that database, the startup procedure does not run.