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 PreviousNext

UpChapter 4 Examples of Using the DB Access Class Library
Up4.2 Use an Object of the FJDB-COMMAND Class

4.2.1 Create a bind table to handle dynamic parameters


Create a bind table to handle dynamic parameters.

A bind table is an object of a COBOL variable.
A bind table is needed to manipulate data by using a recordset or dynamic parameters.
Associating a bind table and dynamic parameters makes data manipulation possible.

Create a bind table associated with the dynamic parameters of the SQL statement explained in Data Update Example.


  1. Define the class name.

    Define the class name of the bind table as "BINDTBL." The class name is an optional name.

    REPOSITORY.
         CLASS    BINDTBL AS "*COB-BINDTABLE".
  2. Define variables.

    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  PRM-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). 
    
  3. Load the variables with values.

    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 the number of dynamic parameters specified in the SQL statement.

         MOVE  3  TO  PRM-NUM. (Number of items to be registered in the bind table)
  4. Create an object of the bind table.

    Using a NEW method, create an object of the bind table as "BIND-A."

         INVOKE BINDTBL "NEW" USING PRM-NUM RETURNING BIND-A.
  5. Register the variables in the bind table.

    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 dynamic parameters.

         INVOKE BIND-A "REGISTER" USING BIND-NO.
         INVOKE BIND-A "REGISTER" USING BIND-NAME.
         INVOKE BIND-A "REGISTER" USING BIND-ADDRESS.

Contents Index PreviousNext

All Rights Reserved, Copyright (C) Alchemy Solutions Inc. 1998-2000