You are on page 1of 3

9/24/2018 IBM MAINFRAME FORUM: Scrollable Cursor in DB2 : Sensitive cursor,insensitive cursor and asensitive cursor!!

More vivekmishra8086@gmail.com Dashboard Sign Out

This blog intends to write on IBM Mainframe Technologies and cover key concepts in Cobol,DB2,CICS,JCL,VSAM and more..

Home Tips&Tricks Useful Links My contact

Tuesday, May 6, 2014

Type Here... Search


Scrollable Cursor in DB2 : Sensitive cursor,insensitive cursor and
asensitive cursor!!
Get posts in your email
Having completed the Basics of CURSOR in db2 ,we know there can be scrollable and non scrollable
cursor. Further more There are two types of DB2 scrollable cursors .(a).Sensitive (b) Insensitive. Email address... Submit

(We will difference between static and dynamic cursors in next post. Here we will see broadly what is
sensitive/insensitive cursor) Blog Posts
To start with we will see first what is an insensitive cursor.Let us see how the keyword
'INSENSITIVE' is used to declare this type of cursor. DB2 (34) JCL (25)
(We will see difference between STATIC and DYNAMIC cursor in next post) COBOL (15) SORT (11) ISPF
(10) SAS (9) VSAM (8) CA7 (3) CICS
(3) REXX (1) SQL (1)
DECLARE C1 INSENSITIVE SCROLL CURSOR FOR
SELECT STAFF_ID,NAME FROM EMP
Followers
....
OPEN C1 Followers (35) Next
...
FETCH C1
..
CLOSE C1
We will see how and where the INSENSITIVE feature is shown below.

Once we open the C1 cursor, a temporary table is created in the WORK File database which holds the
data from the base table ,ie, EMP table. (We must know that to use scrollable cursors we must use
Follow
declared temporary tables.DB2 places the rows returned from the cursor into these Temporary tables.)
TIMELINE T1: The Cursor is opened and result set is fetched. We will see that the base table EMP
and the result table(the result of cursor open statement) is same My unique Blog visits

322,741

Blog Archive

► 2013 (25)
▼ 2014 (34)
STAGE1: The cursor is fetched and Main table and result table looks same
► February (4)
TIMELINE T2 (T2>T1) : After some time T2,user deletes one row from the main table ie the EMP ► March (8)
table.But since the cursor is INSENSITIVE, it does not sense the modification done to the base table, ► April (3)
thereby shows the same rows even though main table has changed.
▼ May (4)
SAS in Mainframes(z/Os)
Tutorial : Use of symbolic...
CURSORS in DB2 and how to
use CURSOR in DB2?
Scrollable Cursor in DB2 :
STAGE2: Row deleted from main table , yet the cursor result table shows the deleted row!! Sensitive cursor,insens...
Static cursors and Dynamic
cursors in DB2
Lets see now SENSITIVE CURSOR:
► June (4)
DECLARE C1 SENSITIVE STATIC SCROLL CURSOR FOR
SELECT STAFF_ID,NAME FROM EMP ► July (1)
.... ► August (4)
Proceeding in the same way, let us review the Timelines T1 and T2 of the cursor life cycle. ► September (1)
TIMELINE T1: The Cursor is opened and result set is fetched. We will see that the base table EMP
► October (2)

http://mframes.blogspot.com/2014/05/sensitive-cursorinsensitive-cursor-and.html 1/3
9/24/2018 IBM MAINFRAME FORUM: Scrollable Cursor in DB2 : Sensitive cursor,insensitive cursor and asensitive cursor!!
and the result table(the result of cursor open statement) is same. This is the same as shown above. ► December (3)
TIMELINE T2 (T2>T1) : After some time T2,user deletes one row from the main table ie the EMP
► 2015 (23)
table.But since the cursor is SENSITIVE, the Temporary table will sense the modification done,ie the
delete and will also delete the corresponding row in the Temporary table. ► 2016 (9)
► 2017 (1)

In Timeline T2, the cursor fetched reflects the same change as the base table EMP.

SENSITIVE CURSOR comes with the combination of SENSITIVE STATIC and SENSITIVE DYNAMIC
Lets look at the FETCH statements for these scrollable type cursors.

All the possible FETCH options are shown here

To FETCH 5th Row from beginning of the Result set:


FETCH SENSITIVE ABSOLUTE +5 FROM C1
Fetch the FIRST ROW
FETCH SENSITIVE FIRST FROM C1
Move forward:
FETCH NEXT FROM C1
Move Backward:
FETCH PRIOR FROM C1
Fetch 5th last row:
FETCH ABSOLUTE -5 FROM C1

RELATIVE n - will FETCH the row that is n rows away from the last row fetched
ABSOLUTE n - will FETCH the row that is n rows away from the first row in the results set

Posted by Rikdeb Mukherjee

Labels: COBOL, DB2

2 comments:

lee woo 7/04/2016 08:15:00 AM


There are certain things I don't want to joke about. If it's about somebody else, it's fine. If it's about me, I
think it's totally insensitive!
See the link below for more info.

#insensitive
www.ufgop.org
Reply

Replies

Anonymous 5/22/2018 04:03:00 PM


.....
......
...

Reply

http://mframes.blogspot.com/2014/05/sensitive-cursorinsensitive-cursor-and.html 2/3
9/24/2018 IBM MAINFRAME FORUM: Scrollable Cursor in DB2 : Sensitive cursor,insensitive cursor and asensitive cursor!!

Enter your comment...

Comment as: RanmaHalf (Google) Sign out

Publish Preview Notify me

Links to this post


Create a Link

Newer Post Home Older Post

Subscribe to: Post Comments (Atom)

Interpreting TSO ISRDDN command in mainframe ISPF


Zoned Decimal and packed Decimal (COMP- 3) fields. How Does COMP 3 saves storage space?
COALESCE function in DB2 . Alternative to NULL indicator variable in DB2 ; SQLCODE - 305.
RENT compiler option in cobol - Understanding reentrant programming
FETCH FIRST N ROWS Vs OPTIMIZE FOR N ROWS in DB2

Powered by Blogger.

http://mframes.blogspot.com/2014/05/sensitive-cursorinsensitive-cursor-and.html 3/3

You might also like