The Placement of Host Variable in an Application Program

As you all know that the Host Variable are nothing but the variable which are host language (Cobol ) equivalent of DB2 table coloumn.
You can create this variable manually or using the tool DCLGEN (Declaration Generator) and then intern include in your Application Program.

There are couple of ways you can place this host variable in your program
1> Include in your program by using following statement in working-storage section.
       EXEC SQL
                  INCLUDE < Member Name >
       END-EXEC.
Member name should be the member in PDS which contains these host variable definition and you should provide this PDS Library in your JCL.
OR
2> Directly put your Host variable declaration in your working-storage section as normal cobol variable.

You cannot put your host variable in program by using COPY statement as you can do in case of normal cobol variable.This is because the statement within INCLUDE get expanded at DB2 precompilation time while the COPY get expanded at compilation time.

Lets say if you put your host variable declaration in COPY statement then at the DB2 precompilation time you will get the "Undeclared host variable " error.


So try to avoid this pitfall in case of placement of host variable in your application program.



2 comments:

Anonymous said...

Very Nice Explanation Nitin.Thank you.... :)

Anonymous said...

I've been browsing online more than three hours as of late, but I by no means found any fascinating article like yours. It is beautiful price enough for me. In my opinion, if all web owners and bloggers made good content as you probably did, the web shall be a lot more helpful than ever before.

Feel free to surf to my web page :: declaring bankruptcy in florida

Post a Comment