View previous topic :: View next topic
|
Author |
Message |
indus
New User
Joined: 10 Dec 2008 Posts: 12 Location: Bangalore
|
|
|
|
1. Is it possible to pass an array to a sub program from main program?
My ans: It is Possible.
2.Can subscript be used instead of index in search.
I did not know the answer.
3.Is it mandatory to use SQLCA in a program:
My ans: It is not mandatory. But if we use it, then only the sql return codes will be available for the program.
4. Can you create a timestamp error for me.
How?
I could not answer that.
Can anyone help me in finding the correct answers.
indus |
|
Back to top |
|
|
Lijo
New User
Joined: 24 Aug 2008 Posts: 41 Location: Cochin
|
|
|
|
I don't know if this is going to be the correct answers, but just sharing my views so that I'll get to know if these are correct:
1. Yes. But you need to pass 'number occurrences of array' also to the receiving program. Then only it can read until that count and fetch individual array elements.
2. My answer is Subscript can't be used in SEARCH clause. But it can used to find an array element, for example: MOVE EMP-ARRY (EMP-NO) to WS-EMP-DETAILS. Here, EMP-NO can be a sub script.
Index is a variable which is not declared/defined anywhere in the COBOL program apart from the mention in OCCURS clause, where as subscript is normally defined in working storage section. When you use a defined variable (subscript) in OCCURS clause, you will get an error as OS try to allocate that variable again. When you do a SEARCH statement, it automatically picks up the index in OCCURS clause and starts search operation.
3. I think you must include SQLCA (SQL Communication Area) in DB2 application program. We'll be using SQLCA variables (at least SQLCODE) to check the success of a query.
4. I suppose by timestamp error you mean -818. To create a -818 (THE PRECOMPILER-GENERATED TIMESTAMP x IN THE LOAD MODULE IS DIFFERENT FROM THE BIND TIMESTAMP y BUILT FROM THE DBRM z ), after making some code changes just do a compilation and link-edit with out binding. Execute the COBOL program. You can see -818. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
For number 2, contrary to Lijo's post, a subscript can be used for a serial search. Click on the manuals link at the top of the page, pull up the COBOL Language Reference manual, and look at section 6.2.32 on the SEARCH verb. Binary search doesn't work with a subscript, but you didn't say SEARCH ALL, just SEARCH. Further, a serial search requires an index or subscript to be specified -- it won't "automatically pick(s) up the index in OCCURS clause and starts search operation". |
|
Back to top |
|
|
indus
New User
Joined: 10 Dec 2008 Posts: 12 Location: Bangalore
|
|
|
|
Lijo,
I have a doubt regarding SQLCA usage.
It is not mandatory to use SQLCA rt...With out sqlca also we can have a COBOL-DB2 program. But for checking for return codes we need SQLCA. But that does not mean that it is mandatory.
Just wanted to confirm this doubt... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
It is not mandatory to use SQLCA rt...With out sqlca also we can have a COBOL-DB2 program. |
The db2 CALLs generated by the preprocessor refer to sqlca. Without sqlca, the compile fails (at least on the systems i currently support). . . I ran a little test to be sure |
|
Back to top |
|
|
indus
New User
Joined: 10 Dec 2008 Posts: 12 Location: Bangalore
|
|
|
|
Thank you very much for that clarification Dick |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome
d |
|
Back to top |
|
|
Lijo
New User
Joined: 24 Aug 2008 Posts: 41 Location: Cochin
|
|
|
|
Thanks Robert for the clarification on point 2. |
|
Back to top |
|
|
|