As far as I know, we use INCLUDE in COBOL-DB2 programs to copy the contents of the DCLGEN to the program.
The only difference between INCLUDE and COPY is that while INCLUDE is executed at pre-compile time (by the SQL compiler), COPY is executed at compile time(by the COBOL compiler).
Hence, you can even use COPY for your DCLGEN's but you may get a return code of 4 from the precompiler because the pre-compiler searches for the host variables used in a query and if it does not find them returns 4.
Please do correct me if i am wrong.
vinaykumar
Jul 22nd, 2011
First, if the delimiters surrounded an INCLUDE statement, the Precompiler goes to the INCLUDE library named in the job control language data definition statement and pulls the included MEMBERNAME into the program.
This function is the same as a COBOL COPY MEMBERNAME, but the timing is different. COBOL COPYBOOKs get copied in at COMPILE time; DB2 INCLUDEs get copied in at precompile time. The only difference between an SQL INCLUDE and a COBOL COPY is timing.
I have used COPY in simple COBOL program (without DB2) and my program got compiled with return code 0. I think we can use the COPY for programs which doesnt use DCLGEN? Plz correct me if I am wrong.
Copy will be used in the cobol compile process and Include will be used during the Db2 precompile process. So we include a Dclgen. We cannot copy a dclgen..If so the program will fail the compilation.We can include a copybook too.
Srinivas Enumula
Sep 8th, 2017
Copy - Expand the copybook statements during compilation time.
Include - Expand the copybook statements during pre-compilation time. Usually for DELGENS we use INCLUDE as DCLGEN statements needed during pre-compilation process.
What is the difference between COPY and INCLUDE
Questions by itsme20 answers by itsme20
Related Answered Questions
Related Open Questions