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.3 Execute an SQL Statement Directly

4.3.1 Execute an SQL statement to update data

Databases can be updated by updating, deleting, or inserting rows without using recordsets or objects of the FJDB-COMMAND class.
A bind table need not be created.
Use the EXECUTE-SQL method in the FJDB-DATABASE class to update a database.

This section introduces an example of deleting a row from the database to which rows have been added in Update data using a recordset.


  1. Define variables.

    Define the variables to use in the program.

     WORKING-STORAGE SECTION.
    *Define the data setup variables
     01 XSQL       PIC X(255).
    *Define the data return variable
     01 ROW-COUNT  PIC S9(9) COMP-5.
    *Define the return value variable
     01 RET-CODE   PIC S9(9) COMP-5.


  2. Execute an SQL statement.

    Using the EXECUTE-SQL method in the FJDB-DATABASE class, execute an SQL statement directed at the database.

    (1) Assign the SQL statement that is specified when an EXECUTE-SQL method is issued to the variable (XSQL).

         MOVE "DELETE FROM EMPLOYEE WHERE NO = 2000" TO XSQL.

    (2) Issue an EXECUTE-SQL method.
    The data is deleted from the database.

         INVOKE DATABASE-A "EXECUTE-SQL" USING XSQL ROW-COUNT 
                                           RETURNING RET-CODE.
         DISPLAY "COUNT= " ROW-COUNT.



Contents Index PreviousNext

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