Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 14:- Database Interface


DB2 Application Programming

COBOL-DB2 interface is governed by following rules:-

  • Embedded SQL statement must be enclosed between “EXEC SQL” and “END-EXEC”
  • Example:-

    EXEC SQL        SELECT EMP-ID INTO :WS-ID FROM EMP END-EXEC.

  • Each EXEC SQL ... END-EXEC block must contain only one SQL statement.
  • If the SQL command is not terminated by an END-EXEC operand, a COBOL compiler error will be generated.
  • All SQL statements must be coded in Margin B.
  • All SQL statements except INCLUDE and DECLARE must be coded in PROCEDURE DIVISION
  • Structure (or Definition) of all the DB2 tables used withing program should have been included in WORKING-STORAGE SECTION using EXEC SQL INCLUDE statement
  • All the Host Variables used in program must be declared in WORKING-STORAGE SECTION.
  • Always suggested to include SQLCA to track SQL return code of executed SQL Statement. SQLCA is explained in following section.






© copyright mainframebug.com
Privacy Policy