Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic COBOL and DB2 questions from a newcomer to the language 3

Status
Not open for further replies.

widowweeds

Programmer
Oct 29, 2002
14
IE
Can any member assist me with answers and examples to the following questions:

1.What is a DBRM?
2.Why is it not necessary to bind when using a DBRM?
3.What is the COBOL syntax for defining an attribute?
4.What is the COBOL syntax for defining an attribute or a number of attributes where both a single dimensional and two dimensional array are concerned?
5. How many bytes of storage does a field with a picture clause of S9(9) usage binary (usage comp) occupy?
6. What is a synonym?
7. Why is a synonym used (example)?
8. How are nulls returned by a fetch normally handled?

Many thanks in advance for any assistance given.

widowweeds.
 
You asked, "5. How many bytes of storage does a field with a picture clause of S9(9) usage binary (usage comp) occupy?"

This is answer in this thread:
thread209-205700 Tom Morrison
 
1) When compiling a DB2 Cobol program, the first step is a pre-compile step which runs through the code and identifies all the db2 elements. These are written to a file called a DBRM, along with a timestamp.

2) After the load module has been produced (usually) a BIND step is executed. This takes the DBRM dtails and writes them to the SYSIBM tables referencing them with a PLAN or a PACKAGE. When the load module is executed this PLAN or PACKAGE name is given, and the timestamp on the load module must match that on the DBRM. I think that if a Cobol program has dynamic SQL, a BIND is not performed (although I'm not certain of this) and this process occurs at runtime with a PREPARE statement. Dynamic SQL is therefore less efficient than the same SQL statement that has been previously 'bound'.

3) and 4) I'm not quite sure what you mean by the terminology 'attribute'. Could you care to elaborate.

6) A synonym is a way of referencing a DB2 table without knowing it's proper table name.

7) A Cobol program could reference a synonym called EMPLOYEE which would point to a testing table. By dropping and re-creating the synonym, you could make the program look at different data without having to re-compile it. I think that in this circumstance, you would need to re-bind the plan though (unless the system had been set up with automatic re-bind)

8) Nulls are handled in two ways. You can either check for an SQLCODE -305 or, when fetching, add an extra variable (format PIC S9(4) COMP) to the receiving field which will contain either a 0 (found) or -1(null). Swings and roundabouts for which one you choose.

Hope this helps

Marc
 
Dear Marclodge,

Many thanks for taking the time and trouble to reply to the questions above.

The question relating to attributes was posed in a recent technical test and which I was unable to answer at the time because I had never come across it before. To the best of my recollection we were asked to give an example of a 4 x 3 two dimensional array and code two "attributes" (the examiner's words, not mine) in association with the array. I cannot recall the names of the attributes wanted but I use attributes when coding in DBL/Synergy for screen display such as bold, inverse bold, blink, underline etc., and I took it that this was something similar. I just did not know the syntax in relation to it where COBOL was concerned. Maybe I am totally wrong on this though.
 
Hi WW,
Strange question that I think I might have failed too! I would associate attributes with DB2 tables (as in Null attributes) or displays, as you suggest. Not sure where an array comes into it. Maybe they just wanted to know if you knew how to code a single and two dimensional array?
Marc
 
Dear Marc,

Maybe the question was set wrong or posed as an intentional red herring!

Many thanks once again for the expert insight on this matter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top