Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Cursors can be declared in both working-storage & procedure
division, Agreed.
But is there any difference? If could you please suggest
what is the difference.
TIA

Answer Posted / arthi

Please refer the answer by Marcus_A here:
http://www.dbforums.com/db2/896592-cursor-declaration.html

This is the most concise answer I could find on the net, and it proves that there is no difference in the placement of the declare cursor.

Quoting from the page:

==============
The Declare Cursor SQL statement is not a procedural SQL statement. It is actually part of the Open statement for the Cursor it refers to, and can be placed anywhere in program source code as long as it is physically before the Open SQL statement. It can actually be placed in the Identification Division, although traditionally it is placed in the Working Storage Section.

If you were to examine the compile listing of your program, you will see that the DB2 pre-compiler did not generate a separate call to DB2 for the Declare Cursor (since it is really part of the Open statement for that Cursor).

The problem with placing the Declare Cursor in the Procedure Division is that programmers invariably place code right after the Declare Cursor to check the SQL return code. So what ends up happening is that the SQL code of a previously executed SQL statement gets checked by the program, and if a non-zero return code is acceptable (not an abend condition) for a previous Select statement (such as return code +100), then the program will get confused and often think an abend condition has occurred.

So, if you do put the Declare cursor in the Procedure Division (not a good idea in my opinion) then make absolutely sure that no user code is executed to check the SQL return code for Declare Cursor.

==============

Is This Answer Correct ?    11 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is copy pending status in db2?

1104


How do I optimize a query in db2?

1081


Mention the length of physical storage of the given data types of db2 – date, timestamp, time

1067


What is meant by union and union all?

987


What is the physical storage length of date data type?

1234


Mention the definition of cobol in varchar field.

1227


How to find primary key of a table in db2?

1049


What is dbrm in db2 database?

1093


What is plan in cobol db2?

1114


What do you mean by storage group (stogroup)?

1024


What is consistency token in db2?

1114


How to execute stored procedure in db2 command editor?

1034


What is clone table?

1029


How does db2 sample database connect?

1013


Explain the contention situations caused by locks?

1053