Why Are Server-side Cursors Important?


For over a decade, T-SQL Server and other DBMS developers have been using server-side cursors to access their databases and scroll through updateable rowsets. A server-side cursor in its purest form is simply a block of pointers to live data rows as defined by a SELECT statement. The cursor can include all rows from a specific table or just a selected few. It can address rows generated from a JOIN, view, or stored procedure. Again, when you create a server-side cursor, you aren't asking for data; you're asking for pointers to the data. This means that the data remains where it should remainon the server, where other clients can see and change the values. When you fetch rows from a server-side cursor, you are fetching the "live" dataas it is on the server that instantnot some cached version that's been sitting around in memory for a few seconds to a few days.

Server-side cursors were implemented in the earliest versions of RDO and as the default cursor in ADO classic. This "connected" data access paradigm assumes that the database connection remains in place while the application runs a query and builds a server-side structure that permits one to browse up and back through a set of rows that can be retrieved and updated as needed.

Server-side cursors are especially useful when working with highly interactive applicationsespecially when the application cannot work with disconnected (static) data. This type of application needs a mechanism to work with a single row or a small set of rows at once. Server-side cursors are designed to meet this need. As illustrated by the examples in this appendix, I'll show you how to:

  • Create a cursor based on a focused SELECT statement

  • Position a cursor to any designated row

  • Change the data in the currently selected cursor row

  • Adapt the cursor so other users' changes are visible (or not)




Hitchhiker's Guide to Visual Studio and SQL Server(c) Best Practice Architectures and Examples
Hitchhikers Guide to Visual Studio and SQL Server: Best Practice Architectures and Examples, 7th Edition (Microsoft Windows Server System Series)
ISBN: 0321243625
EAN: 2147483647
Year: 2006
Pages: 227

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net