| 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
The procedural steps for updating data by using an object (recordset) of the FJDB-RECORDSET class and a bind table is described below.
For the procedure for creating a recordset, see "Create an object of the FJDB-SESSION class," "Connect to a database," "Create a bind table to handle data in the recordset," and "Reference data using a recordset."
This section provides an example of updating a recordset called "RECORDSET-A," as used in "Reference data using a recordset (by deleting and adding data) and then allowing the search result to be reflected in the database.
For summary information on the operation, see Data Update Example.
Using the MOVE-FIRST method in the FJDB-RECORDSET class, locate the current row of the recordset on the first row.
INVOKE RECORDSET-A "MOVE-FIRST" RETURNING RET-CODE.
If the data in the field "NO" in the recordset is less than 1000, delete the "No," "NAM" and "ADDRESS" data from the database.
PERFORM TEST BEFORE UNTIL RECORDSET-A::"IS-EOF" NOT = 0
IF BIND-NO < 1000 THEN
INVOKE RECORDSET-A "DELETE-RECORD" RETURNING RET-CODE
END-IF
INVOKE RECORDSET-A "MOVE-NEXT" RETURNING RET-CODE
END-PERFORM.
Add data to the recordset to update the database.
(1) Using an ADD-NEW-RECORD method, add a row to the recordset.
INVOKE RECORDSET-A "ADD-NEW-RECORD" RETURNING RET-CODE.
(2) Assign additional data to the variables registered in the bind table.
MOVE 2000 TO BIND-NO.
MOVE "Kurita" TO BIND-NAME.
MOVE "Tokyo" TO BIND-ADDRESS.
(3) Using an UPDAT-RECORD method, update the recordset and the database with the data set in the bind table.
INVOKE RECORDSET-A "UPDATE-RECORD" RETURNING RET-CODE.
4.1.5.1 Data Update Example (Using a recordset to update data)
Contents
Index
![]()
|