Updating with a Server-Side Cursor


While the example program written for this appendix does not attempt to update the cursor data, it's not that hard to do (though it does expose a much wider set of issuesfodder for another appendix). Suffice it to say that the cursor can be updated through use of the CURRENT OF expression in the UPDATE statement's WHERE clause. For example, to position to a specific row (based on the cursor row, 1 to @@CURSOR_ROWS) and update that row, you could code a routine like the one shown in Figure IV.5.

Figure IV.5. Executing the UPDATE statement using the WHERE CURRENT OF option.





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