Names the database to be accessed in a program or program module and specifies to RDML which database to use and where to declare variables. However, RDML does not attach to the database when it encounters the DATABASE statement. The READY statement causes an attach to the database. The only required parameter for the DATABASE statement is the database name. The name must be the file name that represents the database file or a logical name that resolves to a file name. You can also specify the following: o A database handle o The scope of the database handle o Different sources of the database definition for compilation and execution o DBKEY scope You can specify whether the scope of each record's database key (dbkey) is valid through a COMMIT statement in each of your transactions, or through a FINISH statement. See the explanations for DBKEY SCOPE FINISH and DBKEY SCOPE COMMIT in the Arguments section fro details.
1 – Examples
The following programs demonstrate how to specify a COMPILETIME and RUNTIME database as the same database. Because a RUNTIME database is not explicitly declared, the programs use the COMPILETIME database at runtime also.
1.1 – C Example
#include <stdio.h> DATABASE PERS = FILENAME "PERSONNEL"; main () { READY PERS; START_TRANSACTION READ_ONLY; /* perform some action on the database */ COMMIT; FINISH; }
1.2 – Pascal Example
program db (input,output); DATABASE PERS = FILENAME 'PERSONNEL'; begin READY PERS; START_TRANSACTION READ_ONLY; (* perform some actions on the database *) COMMIT; FINISH; end.
2 – Format
(B)0[mINVOKE [4mDATABASE[m qqqqqqqqwqqqqqqqqqqqqq>qqqqqqqqqqqwqqqqqqqqqqqqqqqqk mqq> db-handle-options qqqj x x lqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj mqwqqqqqqqqqq>qqqqqqqqqwqqwqq> [4mPATHNAME[m qqq> path-name qqwqqk mqq> COMPILETIME qqqj mqq> [4mFILENAME[m qqq> file-spec qqj x lqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj mqwqqqqqqqqqqqqqqqqqqqqqqqqqq>qqqqqqqqqqqqqqqqqqqqqqqqqqqwqqk mqq> [4mRUNTIME[m FILENAME qqqqwqqqq> file-spec qqqqqqqqwqqj x mqqqq> host-variable qqqqj x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj mqqqqwqqqqqqqqqqqqqqqqqq>qqqqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqk mq> [4mDBKEY[m [4mSCOPE[m IS qqwq> [4mCOMMIT[m qqqqqqqu x mq> [4mFINISH[m qqqqqqqj x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj mqwqqqqqqqqqqqqqqqqqqqqqq>qqqqqqqqqqqqqqqqqqqqqqwqqq> mq> [4mREQUEST_HANDLE[m [4mSCOPE[m IS qwq> [4mDEFAULT[m qqwqqj mq> [4mFINISH[m qqqj (B)0[mdb-handle-options = qqqqqqqwqqqq> db-handle q> = qwqqqqqqqqqqqqqqqqqqwwq> x mq> handle-scope qqjx x x mqqwq>qqqqqqqqqqqqqqqqwqq> db-handle qq> = qqqj x x mq> handle-scope qqj (B)0[mhandle-scope = qqwqqqqqwqqwqqq> [4mGLOBAL[m qqqqqqqqwqqwqqqqqwq> m> [ qj x x m> ] qj tqqq> [4mEXTERNAL[m qqqqqqu x x mqqq> [4mLOCAL[m qqqqqqqqqj
2.1 – Format arguments
db-handle-options Database handle options. Allows you to specify a database handle and its scope. db-handle Database handle. A host variable used to refer to a specific database you have invoked. For more information see the entry on the Database Handle clause. handle-scope Specifies the scope of the database handle. Note that you can enclose the scope of a database handle in brackets, for example: [GLOBAL]. GLOBAL Specifies that the database is global to all modules in an image. This allows you to have a single transaction across multiple modules. EXTERNAL Specifies that the database is actually accessed through another module. LOCAL Specifies that the database is local to the module in which it is declared. COMPILETIME The source of the database definitions when the program is compiled. For Oracle Rdb this can be either a CDD path name or a file specification. If you specify only the compiletime identifier and omit the run-time identifier, Oracle Rdb uses the compile-time identifier for both compiling and running the program. For example, RDML will mistakenly use 'CDD$TOP.PERSONNEL' as the run-time database file name in the following example: DATABASE COMPILETIME PATHNAME 'CDD$TOP.PERSONNEL'; However, RDML will correctly interpret the following: DATABASE COMPILETIME PATHNAME 'CDD$TOP.PERSONNEL' RUNTIME FILENAME 'PERSONNEL'; path-name A full or relative CDD path name, enclosed in quotation marks, specifying the source of the database definition. Use single quotes (' ') when the host language is Pascal. Use double quotes (" ") when the host language is C. file-spec File specification. A full or partial file specification, or logical name enclosed in quotation marks, specifying the source of the database. Use single quotes (' ') when the host language is Pascal. Use double quotes (") when the host language is C. RUNTIME FILENAME The source of the database definitions when the program is run. This can be either a file specification or a host variable. If you do not specify this parameter, Oracle Rdb uses the compile- time identifier for both compiling and running the program. host-variable A valid host language variable that equates to a database file specification. DBKEY SCOPE COMMIT The DBKEY SCOPE clause controls when the database key (dbkey) of an erased record may be reused by Oracle Rdb. When the DBKEY SCOPE is COMMIT, (the default), Oracle Rdb cannot reuse the DBKEY of an erased record (to store another record) until the transaction that erased the original record completes (by entering COMMIT). If the user who erased the original record enters a ROLLBACK statement, then the dbkey cannot be reused by Oracle Rdb. DBKEY SCOPE FINISH Controls when the dbkey of an erased record may be reused by Oracle Rdb. When DBKEY SCOPE IS FINISH, Oracle Rdb cannot reuse the dbkey (to store another record) until the user who erased the original record unbinds from the database (usually, by issuing a FINISH statement). With DBKEY SCOPE FINISH, an RDML program can complete one or several transactions and, while still attached to the database, use the dbkey obtained during a STORE operation to directly access those records. REQUEST HANDLE SCOPE RDML automatically initializes any request DEFAULT handles it generates that are in the same compilation unit as the FINISH statement. RDML does not reinitialize any user- specified request handles nor does it reinitialize any request handles that are outside of the compilation unit where the request is initiated. With this option, the value of the request handle is not set to zero after the RDML FINISH statement executes. REQUEST_HANDLE SCOPE DEFAULT is the default. REQUEST HANDLE SCOPE The value of the request handle is set FINISH to zero after the RDML FINISH statement executes. The SQL FINISH statement initializes all request handles in all compilation units in a program. The RDBPRE and RDML preprocessors allow programs to define and manipulate request handles. If you do not want your request handles to be reinitialized, then you must use RDML or RDBPRE (not SQL) to do the attach, and you must use REQUEST_HANDLE SCOPE IS DEFAULT.