GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Mainframe  >  DB2
Go To First  |  Previous Question  |  Next Question 
 DB2  |  Question 195 of 198    Print  
Exec sql and End exec
why do we declare include in between exec sql and end exec and why cant we declare copybook in place of include. Is their any reason why we declare include only


  
Total Answers and Comments: 4 Last Update: September 18, 2009     Asked by: Gowrikalepalli 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Radha3
 
INCLUDE is a pre-compiler statement so it should be coded within the scope of EXEC SQL and END-EXEC.

    INCLUDE is expanded during pre-compilation tome but COPY is expanded during compilation time and so declaration of host variable in copybook will produce errors during pre-comilation.

Above answer was rated as good by the following members:
guraddiv, anubijo
July 17, 2008 06:33:54   #1  
Radha3 Member Since: July 2008   Contribution: 1    

RE: Exec sql and End exec
INCLUDE is a pre-compiler statement so it should be coded within the scope of EXEC SQL and END-EXEC.

INCLUDE is expanded during pre-compilation tome but COPY is expanded during compilation time and so declaration of host variable in copybook will produce errors during pre-comilation.

 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
March 04, 2009 02:36:53   #2  
Lavanya tadakamadla Member Since: March 2009   Contribution: 2    

RE: Exec sql and End exec
INCLUDE is opened by DB2 pre-processor; COPY is opened by COBOL compiler.
Include member is opened while pre-compilation where as COPY member is opened while compilation of the Cobol program.

 
Is this answer useful? Yes | No
April 30, 2009 11:30:54   #3  
memays Member Since: November 2007   Contribution: 5    

RE: Exec sql and End exec
It all has to do with the sequence of compiling a program with imbedded SQL. It is important to understand that a COBOL program with SQL statements will actually go through 2 steps in the compile process - The Pre-Compile(SQL) followed by the COBOL compile.

The EXEC SQL END-EXEC and everything in between are not COBOL statements and the COBOL compiler will not recognize them. The Pre-compiler step takes the EXEC SQL statements and converts them to the equivalent source code that COBOL will understand. The converted output from the pre-compile is then passed to the COBOL compiler in the 2nd step. It is for this reason that any data areas needed by the Pre-Compile step need to be included via a EXEC SQL INCLUDE statement.

If you are also writing CICS COBOL with SQL then you will have 2 pre-compile steps for CICS and SQL followed by a COBOL compile step.

 
Is this answer useful? Yes | No
September 18, 2009 08:53:50   #4  
ABSS1981 Member Since: September 2009   Contribution: 1    

RE: Exec sql and End exec
In addition to the answers posted one of the additional things to have an INCLUDE between EXEC SQL and END-EXEC is that:

You INCLUDE most likely will be a DCLGEN and it is going to have non COBOL language variables that is the table column names which you are likely to refer in the COBOL DB2 program.
In order to enable the compiler understand the non COBOL words (underscore in the table column names) the INCLUDE is between EXEC SQL and END-EXEC

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape