Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 4.07 KB

File metadata and controls

69 lines (49 loc) · 4.07 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Using Cursors (ODBC)
ODBC supports a cursor model that allows several types of cursors, scrolling/positioning within a cursor, several concurrency options, and positioned updates.
markingmyname
maghan
03/14/2017
sql
native-client
reference
SQL Server Native Client ODBC driver, cursors
ODBC cursors, about ODBC cursors
ODBC applications, cursors
cursors [ODBC]
ODBC cursors

Using Cursors (ODBC)

[!INCLUDESQL Server Azure SQL Database Synapse Analytics PDW]

ODBC supports a cursor model that allows:

  • Several types of cursors.

  • Scrolling and positioning within a cursor.

  • Several concurrency options.

  • Positioned updates.

ODBC applications rarely declare and open cursors or use any cursor-related [!INCLUDEtsql] statements. ODBC automatically opens a cursor for every result set returned from a SQL statement. The characteristics of the cursors are controlled by statement attributes set with SQLSetStmtAttr before the SQL statement is executed. The ODBC API functions for processing result sets support the full range of cursor functionality, including fetching, scrolling, and positioned updates.

This is a comparison of how [!INCLUDEtsql] scripts and ODBC applications work with cursors.

Action [!INCLUDEtsql] ODBC
Define cursor behavior Specify through DECLARE CURSOR parameters Set cursor attributes by using SQLSetStmtAttr
Open a cursor DECLARE CURSOR OPEN cursor_name SQLExecDirect or SQLExecute
Fetch rows FETCH SQLFetch or SQLFetchScroll
Positioned update WHERE CURRENT OF clause on UPDATE or DELETE SQLSetPos
Close a cursor CLOSE cursor_name DEALLOCATE SQLCloseCursor

The server cursors implemented in [!INCLUDEssNoVersion] support the functionality of the ODBC cursor model. The [!INCLUDEssNoVersion] Native Client driver uses server cursors to support the cursor functionality of the ODBC API.

In This Section

See Also

SQL Server Native Client (ODBC)
CLOSE (Transact-SQL)
Cursors
DEALLOCATE (Transact-SQL)
DECLARE CURSOR (Transact-SQL)
FETCH (Transact-SQL)
OPEN (Transact-SQL)