Where would you specify the DECLARE CURSOR statement?

db2 sql interview questions

Moderator: Moderator Group

Post Reply
User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Where would you specify the DECLARE CURSOR statement?

Post by Krishna » Sun Mar 29, 2009 10:25 pm

Where would you specify the DECLARE CURSOR statement?

jyoraj
Member
Posts: 1
Joined: Wed Nov 18, 2009 4:42 pm

In Working storage section.

Post by jyoraj » Mon Nov 23, 2009 1:07 pm

In working Storage section.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Mon Nov 23, 2009 5:21 pm

since the question is Where would
my answer would be according to site standards

had the question been Where could
my answer would have been either in Working-Storage, Linkage, or Procedure Division (physically before the OPEN and the FETCH.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

fredrick andrews
Member
Posts: 15
Joined: Thu Feb 23, 2012 6:55 am

Post by fredrick andrews » Thu Feb 23, 2012 8:30 am

Hi dbzTHEdinosauer,

Thanks for the answer.
Sure, we can do it .

But, is there any difference when doing these?

I mean, any performance advantage or anything at all..?

Thanks in advance.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Feb 23, 2012 9:32 am

Fredrick Andrews,

no difference, not performance advantage.

it is cosmetic. by that i mean, it depends on the coding standards for the site.

i have worked at sites and have seen all three methods employed.
just depends on where the coding standards stipulate the code must be layed.

remember, a declare cursor is not an invocation of SQL.
it is used by the pre-compiler to generate the code placed between the PROCEDURE DIVISION statement and the first line of user code.
The inserted code is executed once, regardless of number of times the program is CALLed,
as long as the program is not CANCELed or has the INITIAL statement in the ID Division.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others