[Info-ingres] [Info-Ingres] API Scrollable Cursors ... is this EVIL expected?

Ingres Forums info-ingres at kettleriverconsulting.com
Fri Aug 22 17:33:56 UTC 2014


You don't say what results you are seeing, but I assume that when you
call IIapi_getColumns() on the deleted row you are getting
IIAPI_ST_NO_DATA and thinking that marks the end of the set.  That is
true for non-scrollable updatable cursors and read-only cursors.  For
updatable scrollable cursors, IIAPI_ST_NO_DATA marks both deleted rows
and the end of the set.

There is additional data available for scrollable cursors using
IIapi_getQueryInfo().  After calling IIapi_getColumns() you can call
IIapi_getQueryInfo() (whether you got IIAPI_ST_NO_DATA or not) and take
a look at gq_rowStatus.  Among the info bits, you can check
IIAPI_ROW_DELETED to determine if you have landed on a deleted row or
IIAPI_ROW_AFTER if you have reached the end of the set.  There is also
gq_rowPosition.  Both of these are indicated by IIAPI_GQ_ROW_STATUS
flag.

As for being EVIL, I personally think that anyone who mixes scrollable
and updatable cursors has bought their own ticket for the road to hell
(anyone want to discuss updating columns values such that the row no
longer matches the select criteria).

There were two basic ways to implement row deletions: remove the rows
completely from the set or leave 'holes' in the set where the rows were
deleted and provide a way to detect the deleted rows.  With the first,
deleting rows 5 and 7 of 10 rows (if you deleted row 5, is row 7 still
7, or was it 8?) results in a set of 8 rows with row 6 now row 5 and row
8 now row 6.  So if you want to position to row 6, do you really want to
now position at 5, or at 6 which is actually row 8.  If you delete row
5, where do you end up (if next action is position to current row vs
reading next row, is row 6 (now 5) the result in both cases)?  Evil is
as evil does.

Ingres chose to maintain the set intact with 'holes' where rows are
deleted.  It does mean a little bit of extra gymnastics when
positioning/reading the deleted rows, but it keeps the row references
constant and consistent.


-- 
thogo01
------------------------------------------------------------------------
thogo01's Profile: http://community.actian.com/forum/member.php?userid=4992
View this thread: http://community.actian.com/forum/showthread.php?t=16138




More information about the Info-ingres mailing list