473,473 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do i ensure 'insensitive' (ie static) cursors that are only forward readable (in DB2 for mainframe)??

Dear friends,

I have just run into a strange DB2 problem. Something i'd some of you
would answer, if only shortly.

My basic question is:
How do i ensure 'insensitive' (ie static) cursors that are only forward
readable (in DB2 for mainframe)??

It seems that the cursors i'm working on suddenly have become (after
indexing the primary keys in the tables) - that they have become
'dynamic'.

This mean that the cursor grows when we (eg. on each fetch) insert rows
in table it is opened on.
What gives? Well, when we Fetch and then insert, - well, on the next
fetch i'm getting the row i just inserted!
Ad infinitum.

As far as i remember my cursors where always 'static' pictures of the
table(s) they were opened on. This growing cursor thing is new. I
heard a DBA say that DB2 sometimes does this to "optimize".

I tried forcing a more static cursor by adding the option INSENSTIVE
SCROLL to the cursor declaration, but this makes the cursor forwards &
backwards scrollable, which costs performance wise. The DBA says that
DB2 is forced to do more (set up a new table) when the cursor is made
scrollable.

I'm really not interested in scrollability - only in forward read.
& INSENSITIVE (which we would really like) comes only at the cost of
SCROLL (which we woudn't like).

I'me moving to DB2 version 8 (on MVS) & at the moment the database is
in a "compatibility phase" where we are running DB2 version 8 but only
with version 7 functionality.

Our problem occured ("we believe") because of the adding of indexes, -
this caused DB2 to optimize our cursors in unwanted ways. You know,
maybe this is a problem of constraining the way DB2 optimizes our
cursors? I don't know, which is why i hope some of you answer to this
query.

So i'd like to ask for your take on how to get our cursors to be static
(not 'growable') (while being exclusively read forward) ???

Hope you respond, because the DBA at the installation i am at in
Copenhagen (KMD.dk) is recommonding something a bit ad-hoc:
Just because with have a "INSERT_TIMESTAMP" colon in every table, our
DBA suggested we included in every where clause
" AND INSERT_TIMESTAMP <= CURRRENT_TIMESTAMP "

This seems a bit over the edge. What do we do with databases that do
not have an "INSERT_TIMESTAMP" in every table??

Regards
Paul

Mar 15 '06 #1
3 2278
I'd suspect that you've run into an issue where the addition of an index
has eliminated a sort. A select that sorts the result set before
returning the results will be "static" in that the result set cannot be
changed during the retrieval process. An index based retrieval could
allow a newly inserted row to be retrieved.

This is normally controlled by the isolation level but isolation doesn't
protect you from yourself. If you manually locked the table, preventing
anyone else from using it, you could still insert new rows while you
were fetching.

You may have to alter the SQL to force it to perform a sort, retrieving
all of the data rows before starting to pass them back to you.

The 'evaluate uncommitted' (DSNZPARM) parameter would normally be of
value, but in your case doesn't help. From the Administration Guide
5.8.5.3.8:
" A value of NO specifies that predicate evaluation occurs only on
committed data (or on the application's own uncommitted changes). NO
ensures that all qualifying data is always included in the answer set."

Philip Sherman

sc************@gmail.com wrote:
Dear friends,

I have just run into a strange DB2 problem. Something i'd some of you
would answer, if only shortly.

My basic question is:
How do i ensure 'insensitive' (ie static) cursors that are only forward
readable (in DB2 for mainframe)??

It seems that the cursors i'm working on suddenly have become (after
indexing the primary keys in the tables) - that they have become
'dynamic'.

This mean that the cursor grows when we (eg. on each fetch) insert rows
in table it is opened on.
What gives? Well, when we Fetch and then insert, - well, on the next
fetch i'm getting the row i just inserted!
Ad infinitum.

As far as i remember my cursors where always 'static' pictures of the
table(s) they were opened on. This growing cursor thing is new. I
heard a DBA say that DB2 sometimes does this to "optimize".

I tried forcing a more static cursor by adding the option INSENSTIVE
SCROLL to the cursor declaration, but this makes the cursor forwards &
backwards scrollable, which costs performance wise. The DBA says that
DB2 is forced to do more (set up a new table) when the cursor is made
scrollable.

I'm really not interested in scrollability - only in forward read.
& INSENSITIVE (which we would really like) comes only at the cost of
SCROLL (which we woudn't like).

I'me moving to DB2 version 8 (on MVS) & at the moment the database is
in a "compatibility phase" where we are running DB2 version 8 but only
with version 7 functionality.

Our problem occured ("we believe") because of the adding of indexes, -
this caused DB2 to optimize our cursors in unwanted ways. You know,
maybe this is a problem of constraining the way DB2 optimizes our
cursors? I don't know, which is why i hope some of you answer to this
query.

So i'd like to ask for your take on how to get our cursors to be static
(not 'growable') (while being exclusively read forward) ???

Hope you respond, because the DBA at the installation i am at in
Copenhagen (KMD.dk) is recommonding something a bit ad-hoc:
Just because with have a "INSERT_TIMESTAMP" colon in every table, our
DBA suggested we included in every where clause
" AND INSERT_TIMESTAMP <= CURRRENT_TIMESTAMP "

This seems a bit over the edge. What do we do with databases that do
not have an "INSERT_TIMESTAMP" in every table??

Regards
Paul

Mar 15 '06 #2
Add WITH RR to your cursor declaration to prevent phantom rows.

<sc************@gmail.com> wrote in message
news:11********************@u72g2000cwu.googlegrou ps.com...
Dear friends,

I have just run into a strange DB2 problem. Something i'd some of you
would answer, if only shortly.

My basic question is:
How do i ensure 'insensitive' (ie static) cursors that are only forward
readable (in DB2 for mainframe)??

It seems that the cursors i'm working on suddenly have become (after
indexing the primary keys in the tables) - that they have become
'dynamic'.

This mean that the cursor grows when we (eg. on each fetch) insert rows
in table it is opened on.
What gives? Well, when we Fetch and then insert, - well, on the next
fetch i'm getting the row i just inserted!
Ad infinitum.

As far as i remember my cursors where always 'static' pictures of the
table(s) they were opened on. This growing cursor thing is new. I
heard a DBA say that DB2 sometimes does this to "optimize".

I tried forcing a more static cursor by adding the option INSENSTIVE
SCROLL to the cursor declaration, but this makes the cursor forwards &
backwards scrollable, which costs performance wise. The DBA says that
DB2 is forced to do more (set up a new table) when the cursor is made
scrollable.

I'm really not interested in scrollability - only in forward read.
& INSENSITIVE (which we would really like) comes only at the cost of
SCROLL (which we woudn't like).

I'me moving to DB2 version 8 (on MVS) & at the moment the database is
in a "compatibility phase" where we are running DB2 version 8 but only
with version 7 functionality.

Our problem occured ("we believe") because of the adding of indexes, -
this caused DB2 to optimize our cursors in unwanted ways. You know,
maybe this is a problem of constraining the way DB2 optimizes our
cursors? I don't know, which is why i hope some of you answer to this
query.

So i'd like to ask for your take on how to get our cursors to be static
(not 'growable') (while being exclusively read forward) ???

Hope you respond, because the DBA at the installation i am at in
Copenhagen (KMD.dk) is recommonding something a bit ad-hoc:
Just because with have a "INSERT_TIMESTAMP" colon in every table, our
DBA suggested we included in every where clause
" AND INSERT_TIMESTAMP <= CURRRENT_TIMESTAMP "

This seems a bit over the edge. What do we do with databases that do
not have an "INSERT_TIMESTAMP" in every table??

Regards
Paul

Mar 17 '06 #3
Mark Yudkin wrote:
Add WITH RR to your cursor declaration to prevent phantom rows.


I don't think that this will help since we're talking here about insert
operations in the same transaction. And that is independent of the
isolation level because no isolation is needed, isn't it?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Mar 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rajah Venkata Krishnan | last post by:
I am trying to write updatable cursors in a stored procedure? Can I get any help to write updatable cursors? Any help would be appreciated very much. Thanks for your help in advance. Rajah...
1
by: Kevin Frey | last post by:
Hello, I have a test database with table A containing 10,000 rows and a table B containing 100,000 rows. Rows in B are "children" of rows in A - each row in A has 10 related rows in B (ie. B has...
5
by: Todd Huish | last post by:
I have noticed something disturbing when retrieving datasets over a relatively slow line (multiple T1). I am looking at about 25 seconds to retrieve 500 rows via a php-odbc link. This same select...
5
by: Gustavo Randich | last post by:
Hello, I need to know what's wrong in this translation from Informix. Note the difference in the results, which is due to the UPDATE statement. ORIGINAL PROGRAM (INFORMIX):...
7
by: H. Williams | last post by:
I know the .Net Cursor class doesn't work with color cursors. So I'm currently using the LoadCursorFromFile API with reflection to set color cursors: here is my code: public static extern...
1
by: mrcraze | last post by:
Hi Everyone! We are using a cursor for paging results in SQL server, mainly due to the performance gains achieved when working with large results sets. We have found this to be of great benefit...
0
by: mmones | last post by:
Hello, I 'm working with an IBM DB2 V9 database via ODBC/CLI. I've got a problem with different lock behaviour in the following constellation / configuration. 1) connection C1 and connection...
7
by: Adrian | last post by:
Hi, I want a const static std::set of strings which is case insensitive for the values. So I have the following which seems to work but something doesnt seem right about it. Is there a better...
0
ADezii
by: ADezii | last post by:
A Cursor, in ADO, is the underlying Object that makes it possible to move around within the set of rows returned by a Recordset. The Cursor manages movement, updatability, and currency of the rows...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.