       IDENTIFICATION DIVISION.
       PROGRAM-ID. DBQUERY.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-SQLCODE           PIC S9(9) COMP.
       01 WS-CUSTOMER-NAME     PIC X(40).
       01 WS-ACCOUNT-BALANCE   PIC S9(11)V99 COMP-3.

       LINKAGE SECTION.
       01 LK-ACCOUNT-ID        PIC 9(10).
       01 LK-BALANCE           PIC S9(11)V99.
       01 LK-STATUS            PIC S9(2).

       PROCEDURE DIVISION USING LK-ACCOUNT-ID LK-BALANCE LK-STATUS.
       GET-BALANCE.
           EXEC SQL
               SELECT BALANCE, CUST_NAME
               INTO :WS-ACCOUNT-BALANCE, :WS-CUSTOMER-NAME
               FROM ACCOUNTS
               WHERE ACCOUNT_ID = :LK-ACCOUNT-ID
           END-EXEC.
           MOVE WS-ACCOUNT-BALANCE TO LK-BALANCE.
           MOVE 0 TO LK-STATUS.
           GOBACK.
