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

Module 14:- Database Interface

Embedded SQL

  • Use of SQL statements within source code of your program is known as Embedded SQL.
  • COBOL allows you include Embedded SQL statements in your COBOL programs. Any language interfacing with DB2 is referred to as Host Language. In our case COBOL is Host Language.
  • This feature allows COBOL programmer to directly perform standard SQL operation on database from COBOL program
  • Prior to compilation, an embedded SQL program is processed by a special pre-processor or pre-compiler, which identifies the SQL statements, extracts and pass it to the DBMS for processing.
  • While coding SQL statement in COBOL program, it must be enclosed between “EXEC SQL” and “END-EXEC”
  • Example:-


  • When such Embedded statements are executed, results are stored into COBOL variables referred to as Host Variables. This result storing functionality is achieved by specifying INTO clause in SELECT operation.
  • In above example, “:WS-ID” is Host Variable

© copyright mainframebug.com
Privacy Policy