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