View previous topic :: View next topic
|
Author |
Message |
kvskris Currently Banned New User
Joined: 16 Sep 2006 Posts: 12
|
|
|
|
hello everybody,
i want to know the what is the use of declaring a cursor in the working-storage section rather declaring it in the procedure division.
please help me, this is an interview question.
thanking you all,
kumar |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
IIRC, declaring cursors is not a program executable process, it is needed by the database preprocessor. Putting it in working storage reduces the procedure division clutter. |
|
Back to top |
|
|
nasser_tice
New User
Joined: 28 Nov 2006 Posts: 19 Location: India
|
|
|
|
Hi Thompson,
Could you please explain a little bit clearly to the most Freq. asked Question, what is the diff between declaring a cursor in Procedure Division and Working Storage section....
What happens if we declare it in Procedure Division and What happends if we declare in WS of Data Division..? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
IIRC, nothing happens either way, it is non executable, (I think) it just needs to be visible to the precompiler prior to the cursor beiing used in the procedure division. |
|
Back to top |
|
|
Yuvaraj BP
New User
Joined: 12 Oct 2006 Posts: 12 Location: Bangalore
|
|
|
|
Hai,
To my theoritical knowledge, I think the program will execute successfully but the problem will be with the performance of your program with respect to speed of execution. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Yuvaraj BP wrote: |
To my theoritical knowledge, I think the program will execute successfully but the problem will be with the performance of your program with respect to speed of execution. |
HUH?
A lot of words with little said.....Where does the "performance" difference or problem occur in regards to where the cursor is declared? |
|
Back to top |
|
|
Yuvaraj BP
New User
Joined: 12 Oct 2006 Posts: 12 Location: Bangalore
|
|
|
|
when the cursor is declared in the procedure division execution of your program will be slower than that of declaring it in the ws section |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Yuvaraj BP wrote: |
when the cursor is declared in the procedure division execution of your program will be slower than that of declaring it in the ws section |
I admit it when I do not know the answer, but this I have never heard. Give me a source or reference to this, Please..... |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Yuvaraj ,
I don't think so & I m agree with William Declare cursor is non executable stmt it does not make any difference whether we declare it in working storage or procedure division it should be declare before open cursor stmt. |
|
Back to top |
|
|
nasser_tice
New User
Joined: 28 Nov 2006 Posts: 19 Location: India
|
|
|
|
Yuvraj/Ekta/William,
The answers are not clear as for what happens exactly when we declare a Cursor in Procedure Division and WS Section. \
Can anybody else help on this.. :| |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Replying to a topic that is nearly a year old is usually not recommended.
The answer given in the replies is that it makes no difference. |
|
Back to top |
|
|
|