| DB Access Class Library for COBOL V1.0 API Reference - Microsoft(R) Windows(R) - - Microsoft(R) Windows NT(R) - - Microsoft(R) Windows(R) 2000 - |
Contents
Index
![]()
|
Chapter 4 Examples of Using the DB Access Class Library
4.1 Use a Recordset
To connect to a database, proceed as follows:
Define the class to use in the repository paragraph of the configuration section, and a library of symbolic constants to use in the program in the special-names paragraph.
CONFIGURATION SECTION.
REPOSITORY.
CLASS FJDB-SESSION
CLASS FJDB-DATABASE
CLASS FJDB-ERROR.
SPECIAL-NAMES.
SYMBOLIC CONSTANT
COPY FJDBOPT.
.
Define the variables to use in the program.
WORKING-STORAGE SECTION. *Define object variables 01 SESSION-A USAGE OBJECT REFERENCE FJDB-SESSION. 01 DATABASE-A USAGE OBJECT REFERENCE FJDB-DATABASE. 01 ERROR-A USAGE OBJECT REFERENCE FJDB-ERROR. *Define data setup variables 01 DSN PIC X(10). 01 UID PIC X(10). 01 PWD PIC X(10). 01 SCM PIC X(10). 01 DB-OPT PIC S9(9) COMP-5. *Define the return value variable 01 RET-CODE PIC S9(9) COMP-5.
Load the variables with required information before issuing an OPEN-DATABSE method.
MOVE "DB01" TO DSN. *>Database environment name
MOVE "YODA" TO UID. *>User ID
MOVE "YODA" TO PWD. *>Password
MOVE "GENERAL" TO SCM. *>Default Schema
MOVE FJDB-SCDBOPT-DEFAULT TO DB-OPT. *> Option
Make a connection to a database using an OPEN-DATABASE method.
An object of the FJDB-DATABASE class is created.
INVOKE SESSION-A "OPEN-DATABASE" USING DSN UID PWD SCM
DB-OPT DATABASE-A
RETURNING RET-CODE.
Contents
Index
![]()
|