| 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
Create a bind table to handle data in the recordset.
A bind table is an object of a COBOL variable.
A bind table is needed to manipulate data using a recordset or dynamic parameters. Associating a bind table and a recordset makes data manipulation possible.
Create a bind table associated with the recordset "RECORDSET-A " explained in Data Reference Example and Data Update Example.
Define the class name of the bind table as "BINDTBL." The class name is an optional name.
REPOSITORY.
CLASS BINDTBL AS "*COB-BINDTABLE".
Define the variables to use in the program.
WORKING-STORAGE SECTION. *Define an object variable 01 BIND-A USAGE OBJECT REFERENCE BINDTBL. *Variable for setting a count of the number of items to register in the bind table 01 FLD-NUM PIC S9(9) COMP-5. *Variables for handling data in the recordset 01 BIND-NO PIC S9(9) COMP-5. 01 BIND-NAME PIC X(50). 01 BIND-ADDRESS PIC X(100).
Load the variables with information needed to create a bind table.
The argument that is specified when issuing a NEW method to create a bind table must be greater than or equal to a count of the number of fields in the recordset.
MOVE 3 TO FLD-NUM. iNumber of items to be registered in the bind tablej
Using a NEW method, create an object of the bind table as "BIND-A."
INVOKE BINDTBL "NEW" USING FLD-NUM RETURNING BIND-A.
Using a REGISTER method, register the variables registered in step 2 above in the bind table.
The order in which the variables are registered must match that of fields in the recordset.
INVOKE BIND-A "REGISTER" USING BIND-NO.
INVOKE BIND-A "REGISTER" USING BIND-NAME.
INVOKE BIND-A "REGISTER" USING BIND-ADDRESS.
Contents
Index
![]()
|