Desktop Site
This article has not yet passed wikiHow's quality review process. Learn more

How to Write to a Simple COBOL Program with DB2



This article may need to be cleaned up to meet wikiHow's quality standards.


You can help by improving it and removing this notice when complete. Notice added on 2014-12-02.

The importance of knowing COBOL is quite beneficial even if the language is fifty years old. The language is still being used today to store data in our governments, banks and businesses with little to no signs of changing to newer languages. COBOL programming with DB2 can be very frustrating to learn but the underlying concepts are easier than our thinking and with time anyone can learn it.

Ok,
Close
This article has not yet passed wikiHow's quality review process. Learn more

EditHeadline text

  1. COBOL programs are hierarchical in structure. Each element of the hierarchy consists of one or more subordinate elements. The hierarchy consists of Divisions, Sections, Paragraphs, Sentences and Statements. A Division may contain one or more Sections, a Section one or more Paragraphs, a Paragraph one or more Sentences and a Sentence one or more Statements. We can represent the COBOL hierarchy using the COBOL metalanguage as the below picture.

EditSteps

  1. 1
    To describe the IDENTIFICATION DIVISION supplies information about the program to the programmer and the compiler.
  2. 2
    To write the ENVIRONMENT DIVISION is used to describe the environment in which the program will run. The purpose of this division is to isolate in one place all aspects of the program that are dependant upon a specific computer, device or ending sequence.
  3. 3
    DATA DIVISION - descriptions of the data-information processed by the program. FILE SECTION and WORKING-STORAGE SECTION are included. The LINKAGE SECTION and the REPORT SECTION are additional sections
  4. 4
    Procedure Division - contains the code(To manipulate the data in the DATA DIVISION)
  5. 5
    Minimum COBOL program - For example, the above program is valid when compiled with the Microfocus NetExpress compiler.
  6. 6
    COBOL DB2 PROGRAMMING - Assume we have the following table in DB2(database)
  7. 7
  8. 8
    Host variable declaration VS DB2 - If you use DB2 tool DCLGEN, it will automatically creates this structure and table declaration specified in the table declaration of WORKING-STORAGE SECTION.
  9. 9
    SQLCA in WORKING-STORAGE SECTION
  10. 10
    DB2 sql statement in the PROCECURE DIVISION
  11. 11
    As the above steps, we have completed coding a COBOL-DB2 program.

Did this article help you?

Yes
No