Why to use DB2 DCLGEN instead of COPY?

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
Post Reply
Kamini Gupta
New Member
Posts: 6
Joined: Mon Aug 18, 2014 2:23 pm

Why to use DB2 DCLGEN instead of COPY?

Post by Kamini Gupta »

Hi,

Why to we use DB2 DCLGEN instead of COPY? Can not that make just same impact?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Why to use DB2 DCLGEN instead of COPY?

Post by Robert Sample »

SQL statements are run through a preprocessor before the COBOL compile is done. The COPY statement is a COBOL verb and hence will not be invoked until the compile, which is after the preprocessor has completed. So using a COPY instead of DCLGEN means nothing will be available to SQL since the preprocessor will not have anything to work with.
Kamini Gupta
New Member
Posts: 6
Joined: Mon Aug 18, 2014 2:23 pm

Re: Why to use DB2 DCLGEN instead of COPY?

Post by Kamini Gupta »

Thanks Robert. But if use COPY COPYBOOK with DCLGEN variables, when they will be used by program, program will get them and it will work, right?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Why to use DB2 DCLGEN instead of COPY?

Post by Robert Sample »

The IBM manual at https://www.ibm.com/support/knowledgece ... clgen.html says
The declarations generator (DCLGEN) produces an SQL DECLARE TABLE statement and a COBOL, PL/I, or C data declaration for a table or a view named in the catalog.
So the DCLGEN does the SQL DECLARE TABLE for which the fields can then be referenced in a copy book.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”