Explicitly declares a database closed when you are done working
with it. FINISH with no parameter also commits all active
transactions. It is recommended that you use FINISH before
exiting from a program.
Example:
999-EOJ.
IF BAD-FLAG = 1
THEN
&RDB& ROLLBACK
ELSE
&RDB& COMMIT
&RDB& FINISH
CLOSE JOBHST-FILE.
STOP RUN.
1 – More
If you have invoked a database, you have the necessary privileges
to use the FINISH statement.
When you use INVOKE to declare databases and then use the START_
TRANSACTION statement, the Oracle Rdb preprocessors automatically
attach your process to all the databases you have invoked.
This involves some overhead and record locking. If the FINISH
statement occurs explicitly in the run-time flow of the program,
Oracle Rdb detaches from the database mentioned in the FINISH.
If another START_TRANSACTION occurs, Oracle Rdb attaches to the
databases again. Therefore, if your program uses databases
sequentially, you can use FINISH to close each database as you
are finished working with it. In this way, Oracle Rdb attaches only
the databases you need at any one time.
2 – Format
(B)0[m[4mFINISH[m qqqwqqqqqqqqqqqqqqqqqqqwqwqqqqqqqqqqqqqqqqwqq>
mqwq> db-handle qwqqj mqq> on-error qqqj
mqqqqq , <qqqqqj
2.1 – db-handle
A host language variable that identifies the database to be
accessed. Use the db-handle that you associated with the database
in the INVOKE statement.
2.2 – on-error
Specifies host language statements or Oracle Rdb data manipulation
statements to be performed if an Oracle Rdb error occurs. For more
details, request HELP on ON_ERROR.
3 – Example
The following fragment shows how to use INVOKE and FINISH to work
with two databases:
&RDB& INVOKE DATABASE WORKERS =
&RDB& FILENAME 'DISK2:[DEPT4]EMPLOYEES'
&RDB& INVOKE DATABASE PARTS =
&RDB& FILENAME 'DISK2:[DEPT4]PARTS'
.
.
.
! [This part of the program can combine data from
both databases]
.
.
.
&RDB& FINISH WORKERS
.
.
.
! [This part of the program uses only
the PARTS database]
.
.
.
&RDB& FINISH PARTS
Between the second INVOKE statement and the first FINISH, you can
access both databases at once.