[DB-SIG] Extensions to DB API 2.0

M.-A. Lemburg mal@lemburg.com
Mon, 14 Jan 2002 10:30:54 +0100


brian zimmer wrote:
> 
> >     Cursor Method .scroll(value[,mode='relative'])
> >
> >        Scroll the cursor in the result set to a new position according
> >        to mode.
> >
> >        If mode is 'relative' (default), value is taken as offset to
> >        the current position in the result set, if set to 'absolute',
> >        value states an absolute target position.
> >
> >        An IndexError should be raised in case a scroll operation would
> >        leave the result set. In this case, the cursor position is left
> >        undefined (ideal would be to not move the cursor at all).
> >
> >        Note: This method should use native scrollable cursors, if
> >        available , or revert to an emulation for forward-only
> >        scrollable cursors. The method may raise NotSupportedErrors to
> >        signal that a specific operation is not supported by the
> >        database (e.g. backward scrolling).
> >
> >        Warning Message: "DB-API extension cursor.scroll() used"
> 
> In implementing .scroll() for zxJDBC the underlying JDBC result set's
> absolute scrolling allows for negative numbers for value.  The result
> set then counts backwards from the end of the set much like a Python
> sequence.  I was wondering if the DB API .scroll() supported the same
> semantics?  What should happen for .scroll(-1, "absolute")?  Is this an
> IndexError or does .rownumber become the last row in the result set?

Good question. 

In mxODBC I have implemented the Python sequence
indexing semantics, but this feature is only available if the
database provides the .rownumber information (and not all databases
do).

I'd say, we leave this undefined so it becomes an implementation
detail. The IndexError is really meant for relative moving
in the result set.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/