What is the difference between COPY and INCLUDE

Questions by itsme20   answers by itsme20

Showing Answers 1 - 9 of 9 Answers


  • Mar 20th, 2007

COPY statements are executed at compile time.
INCLUDE executed at run time.

  Was this answer useful?  Yes


  • Feb 13th, 2010

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.


  • 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.

  Was this answer useful?  Yes


  • Jul 27th, 2011

copy and include both are predefined but

COPY will expand at the time of compilation

INCLUDE will expand at the time of pre-compilation process & compilation process doesn't expand INCLUDE stm

& pre-compilation will expand both

pl correct me if it's wrong

  Was this answer useful?  Yes


  • Jul 27th, 2011

include means it expands the statements in the precompilation time but copy means it just retrieves the statements at compile time.

  Was this answer useful?  Yes

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.

  Was this answer useful?  Yes


  • Dec 31st, 2015

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.

  Was this answer useful?  Yes

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.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions