Subject | Re: [IBO] Insert has really to "Fetch All Rows"? |
---|---|
Author | Helen Borrie |
Post date | 2004-08-13T01:26:08Z |
At 09:48 PM 12/08/2004 +0000, you wrote:
see these posts late at night and, when I can't reproduce it, I hope that
someone who has seen the same thing will hop in and try to help. I suppose
most people feel that way. Weird problems usually come from weird
combinations of conditions and simple answers don't always appear like magic.
the dataset has CommitAction caFetchAll.."
This article is about filtering, though, and that observation is saying
that IBO respects the filters when it updates the buffers. Your problem
seems to come from an unfiltered dataset - is that so?
if your KeyLinks are correct, should fetch only the inserted rows after a
commit. Have you accidentally changed this to caFetchAll?
Do you have correct KeyLinks in this dataset?
Are you opening a huge dataset here? No WHERE clause?
Assuming your KeyLinks are correct, do you have FetchWholeRows set to True
or False? When it's true, the dataset refetches all of the columns
whenever it needs to update the buffer. This is quicker if the dataset is
not huge. When it's false, it will first update the key buffer and try to
refresh the dataset from rows it already has in the row buffer. If there
are no keylinks, this won't help, because the key buffer is populated from
the keylinks.
Note: with the default settings for TIBOQuery, posting inserts (even with
AutoCommit true) doesn't cause a FetchAll. It will happen if/when you
explicitly call Refresh on a TDataset. You don't have any control over what
gets requeried.
Are you perhaps calling Refresh somewhere?
Sorry I can't be much help, because *something* is missing in the problem
description. Here's what the monitor shows when I insert a new row into an
unfiltered query over the PROJECT table in the employee.fdb database, with
all default settings, including AutoCommit true:
/*---
EXECUTE IMMEDIATE
DB_HANDLE = 13857612
TR_HANDLE = 13846232
INSERT INTO PROJECT
( PROJ_ID
, PROJ_NAME
, TEAM_LEADER
, PRODUCT )
VALUES
( ? /* PROJ_ID */
, ? /* PROJ_NAME */
, ? /* TEAM_LEADER */
, ? /* PRODUCT */ )
PARAMS = [ Version 1 SQLd 4 SQLn 4
PROJECT.PROJ_ID = 'BLAH3'
PROJECT.PROJ_NAME = 'Blah3'
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'other' ]
----*/
/*---
COMMIT RETAINING
TR_HANDLE = 13846232
----*/
As you see, no refetch follows. IBO invalidates the row after the commit
but we continue to see the newly-inserted row in the grid, just as it was
before the AutoCommit occurred.
Next, I call Refresh.
/*---
CLOSE CURSOR
STMT_HANDLE = 13857344
----*/
/*---
COMMIT
TR_HANDLE = 13846232
----*/
/*---
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 13846232
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 13846232
STMT_HANDLE = 13857344
PARAMS = [ ]
----*/
/*---
OPEN CURSOR
STMT_HANDLE = 13857344
NAME = C1400252431829584
----*/
First, the dataset uses the key of the new record to fetch it into the buffer:
/*---
EXECUTE ROW FETCH
TR_HANDLE = 13846232
STMT_HANDLE = 13846580
PARAMS = [ Version 1 SQLd 1 SQLn 1
PROJECT.PROJ_ID[BIND_0] = 'BLAH3' ]
----*/
/*---
OPEN ROW CURSOR
STMT_HANDLE = 13846580
NAME = C1400904431829583
----*/
/*---
FETCH
STMT_HANDLE = 13846580
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = <n> 'BLAH3'
PROJECT.PROJ_NAME = <n> 'Blah3'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = <n> 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13846580
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = <n> 'BLAH3'
PROJECT.PROJ_NAME = <n> 'Blah3'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = <n> 'other' ]
ERRCODE = 100
----*/
This is the Success code.
/*---
CLOSE ROW CURSOR
STMT_HANDLE = 13846580
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 13846232
STMT_HANDLE = 13846044
PARAMS = [ Version 1 SQLd 1 SQLn 1
PROJECT.PROJ_ID = 'BLAH3' ]
----*/
/*---
OPEN CURSOR
STMT_HANDLE = 13846044
NAME = 13846044C1400252431829584
----*/
/*---
FETCH
STMT_HANDLE = 13846044
FIELDS = [ Version 1 SQLd 1 SQLn 1
PROJECT.PROJ_ID = 'BLAH3' ]
----*/
/*---
CLOSE CURSOR
STMT_HANDLE = 13846044
----*/
Now, it proceeds to get the other records:
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'VBASE'
PROJECT.PROJ_NAME = 'Video Database'
PROJECT.PROJ_DESC = BLOB ID ( 133, 6 )
PROJECT.TEAM_LEADER = 45
PROJECT.PRODUCT = 'software' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'DGPII'
PROJECT.PROJ_NAME = 'DigiPizza'
PROJECT.PROJ_DESC = BLOB ID ( 133, 8 )
PROJECT.TEAM_LEADER = 24
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'GUIDE'
PROJECT.PROJ_NAME = 'AutoMap'
PROJECT.PROJ_DESC = BLOB ID ( 133, 10 )
PROJECT.TEAM_LEADER = 20
PROJECT.PRODUCT = 'hardware' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'MAPDB'
PROJECT.PROJ_NAME = 'MapBrowser port'
PROJECT.PROJ_DESC = BLOB ID ( 133, 12 )
PROJECT.TEAM_LEADER = 4
PROJECT.PRODUCT = 'software' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'HWRII'
PROJECT.PROJ_NAME = 'Translator upgrade'
PROJECT.PROJ_DESC = BLOB ID ( 133, 14 )
PROJECT.TEAM_LEADER = <NULL>
PROJECT.PRODUCT = 'software' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'MKTPR'
PROJECT.PROJ_NAME = 'Marketing project 3'
PROJECT.PROJ_DESC = BLOB ID ( 133, 16 )
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'N/A' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH '
PROJECT.PROJ_NAME = 'Blah'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 4
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH1'
PROJECT.PROJ_NAME = 'Blah1'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 45
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH2'
PROJECT.PROJ_NAME = 'Blah2'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAHH'
PROJECT.PROJ_NAME = 'Blah-blah'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 20
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH3'
PROJECT.PROJ_NAME = 'Blah3'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH3'
PROJECT.PROJ_NAME = 'Blah3'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'other' ]
ERRCODE = 100
----*/
/*---
CLOSE CURSOR
STMT_HANDLE = 13857344
----*/
Helen
>It is my second post with the same question.I saw your other post and tried (unsuccessfully) to reproduce it. Often I
see these posts late at night and, when I can't reproduce it, I hope that
someone who has seen the same thing will hop in and try to help. I suppose
most people feel that way. Weird problems usually come from weird
combinations of conditions and simple answers don't always appear like magic.
>My tables are fetching all rows when I post a TIBOQuery. But it onlyThis (sorry!! -- Author) is an error in the GSG. It should say "Even if
>occurs when I'm inserting in with it using:
>
>TIBOQuery.Insert;
>...
>TIBOQuery.Post
>
>In your "Getting Started" I've read:
>
>"Setting Filters: The TIB_Dataset and its descendants (including the
>TIBODataset) implements filters very well. Whether the dataset has
>FetchAllRows True (i.e. all rows are in the client buffer) or not
>(rows matching filter criteria are fetched on demand), re-setting
>filter criteria can be as simple as passing a parameter or reading a
>value from a control."
the dataset has CommitAction caFetchAll.."
This article is about filtering, though, and that observation is saying
that IBO respects the filters when it updates the buffers. Your problem
seems to come from an unfiltered dataset - is that so?
>But I could not find the property FetchAllRows, I *really* need toBy default, the TIBOQuery has CommitAction set to caInvalidateCursor which,
>disable this feature or to discover a workaround.
>
>Is there a way to solve that?
if your KeyLinks are correct, should fetch only the inserted rows after a
commit. Have you accidentally changed this to caFetchAll?
Do you have correct KeyLinks in this dataset?
Are you opening a huge dataset here? No WHERE clause?
Assuming your KeyLinks are correct, do you have FetchWholeRows set to True
or False? When it's true, the dataset refetches all of the columns
whenever it needs to update the buffer. This is quicker if the dataset is
not huge. When it's false, it will first update the key buffer and try to
refresh the dataset from rows it already has in the row buffer. If there
are no keylinks, this won't help, because the key buffer is populated from
the keylinks.
Note: with the default settings for TIBOQuery, posting inserts (even with
AutoCommit true) doesn't cause a FetchAll. It will happen if/when you
explicitly call Refresh on a TDataset. You don't have any control over what
gets requeried.
Are you perhaps calling Refresh somewhere?
Sorry I can't be much help, because *something* is missing in the problem
description. Here's what the monitor shows when I insert a new row into an
unfiltered query over the PROJECT table in the employee.fdb database, with
all default settings, including AutoCommit true:
/*---
EXECUTE IMMEDIATE
DB_HANDLE = 13857612
TR_HANDLE = 13846232
INSERT INTO PROJECT
( PROJ_ID
, PROJ_NAME
, TEAM_LEADER
, PRODUCT )
VALUES
( ? /* PROJ_ID */
, ? /* PROJ_NAME */
, ? /* TEAM_LEADER */
, ? /* PRODUCT */ )
PARAMS = [ Version 1 SQLd 4 SQLn 4
PROJECT.PROJ_ID = 'BLAH3'
PROJECT.PROJ_NAME = 'Blah3'
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'other' ]
----*/
/*---
COMMIT RETAINING
TR_HANDLE = 13846232
----*/
As you see, no refetch follows. IBO invalidates the row after the commit
but we continue to see the newly-inserted row in the grid, just as it was
before the AutoCommit occurred.
Next, I call Refresh.
/*---
CLOSE CURSOR
STMT_HANDLE = 13857344
----*/
/*---
COMMIT
TR_HANDLE = 13846232
----*/
/*---
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 13846232
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 13846232
STMT_HANDLE = 13857344
PARAMS = [ ]
----*/
/*---
OPEN CURSOR
STMT_HANDLE = 13857344
NAME = C1400252431829584
----*/
First, the dataset uses the key of the new record to fetch it into the buffer:
/*---
EXECUTE ROW FETCH
TR_HANDLE = 13846232
STMT_HANDLE = 13846580
PARAMS = [ Version 1 SQLd 1 SQLn 1
PROJECT.PROJ_ID[BIND_0] = 'BLAH3' ]
----*/
/*---
OPEN ROW CURSOR
STMT_HANDLE = 13846580
NAME = C1400904431829583
----*/
/*---
FETCH
STMT_HANDLE = 13846580
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = <n> 'BLAH3'
PROJECT.PROJ_NAME = <n> 'Blah3'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = <n> 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13846580
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = <n> 'BLAH3'
PROJECT.PROJ_NAME = <n> 'Blah3'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = <n> 'other' ]
ERRCODE = 100
----*/
This is the Success code.
/*---
CLOSE ROW CURSOR
STMT_HANDLE = 13846580
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 13846232
STMT_HANDLE = 13846044
PARAMS = [ Version 1 SQLd 1 SQLn 1
PROJECT.PROJ_ID = 'BLAH3' ]
----*/
/*---
OPEN CURSOR
STMT_HANDLE = 13846044
NAME = 13846044C1400252431829584
----*/
/*---
FETCH
STMT_HANDLE = 13846044
FIELDS = [ Version 1 SQLd 1 SQLn 1
PROJECT.PROJ_ID = 'BLAH3' ]
----*/
/*---
CLOSE CURSOR
STMT_HANDLE = 13846044
----*/
Now, it proceeds to get the other records:
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'VBASE'
PROJECT.PROJ_NAME = 'Video Database'
PROJECT.PROJ_DESC = BLOB ID ( 133, 6 )
PROJECT.TEAM_LEADER = 45
PROJECT.PRODUCT = 'software' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'DGPII'
PROJECT.PROJ_NAME = 'DigiPizza'
PROJECT.PROJ_DESC = BLOB ID ( 133, 8 )
PROJECT.TEAM_LEADER = 24
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'GUIDE'
PROJECT.PROJ_NAME = 'AutoMap'
PROJECT.PROJ_DESC = BLOB ID ( 133, 10 )
PROJECT.TEAM_LEADER = 20
PROJECT.PRODUCT = 'hardware' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'MAPDB'
PROJECT.PROJ_NAME = 'MapBrowser port'
PROJECT.PROJ_DESC = BLOB ID ( 133, 12 )
PROJECT.TEAM_LEADER = 4
PROJECT.PRODUCT = 'software' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'HWRII'
PROJECT.PROJ_NAME = 'Translator upgrade'
PROJECT.PROJ_DESC = BLOB ID ( 133, 14 )
PROJECT.TEAM_LEADER = <NULL>
PROJECT.PRODUCT = 'software' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'MKTPR'
PROJECT.PROJ_NAME = 'Marketing project 3'
PROJECT.PROJ_DESC = BLOB ID ( 133, 16 )
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'N/A' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH '
PROJECT.PROJ_NAME = 'Blah'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 4
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH1'
PROJECT.PROJ_NAME = 'Blah1'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 45
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH2'
PROJECT.PROJ_NAME = 'Blah2'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAHH'
PROJECT.PROJ_NAME = 'Blah-blah'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 20
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH3'
PROJECT.PROJ_NAME = 'Blah3'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'other' ]
----*/
/*---
FETCH
STMT_HANDLE = 13857344
FIELDS = [ Version 1 SQLd 5 SQLn 5
PROJECT.PROJ_ID = 'BLAH3'
PROJECT.PROJ_NAME = 'Blah3'
PROJECT.PROJ_DESC = <NULL>
PROJECT.TEAM_LEADER = 85
PROJECT.PRODUCT = 'other' ]
ERRCODE = 100
----*/
/*---
CLOSE CURSOR
STMT_HANDLE = 13857344
----*/
Helen