块游标Block Cursors

许多应用程序花费大量的时间将跨网络的数据。Many applications spend a significant amount of time bringing data across the network. 这次所用的部分实际上将数据传送跨网络,以及作为其中一部分所用的网络开销,如驱动程序请求数据的行所做的调用。Part of this time is spent actually bringing the data across the network, and part of it is spent on network overhead, such as the call made by the driver to request a row of data. 如果应用程序可以有效地使用后一种时间就会降低块中,fat 游标, 这可以一次返回多个行。The latter time can be reduced if the application makes efficient use of block, or fat, cursors, which can return more than one row at a time.

应用程序始终能够使用块状游标的选项。An application always has the option of using a block cursor. 要从其提取一次只有一个行的数据源,必须在驱动程序中模拟块状游标。On data sources from which only one row at a time can be fetched, block cursors must be simulated in the driver. 这可以通过执行多个单行提取操作。This can be done by performing multiple single-row fetches. 虽然不太可能提供任何性能提升,它会打开应用程序的机会。While this is unlikely to provide any performance gains, it opens opportunities for applications. 此类应用程序然后将使性能提高,如 Dbms 本机实现块状游标并关联与这些 Dbms 的驱动程序公开它们。Such applications will then experience performance increases as DBMSs implement block cursors natively and the drivers associated with those DBMSs expose them.

使用块游标读取一次返回的行被称为行集The rows returned in a single fetch with a block cursor are called the rowset. 务必不要将混淆的结果集与行集。It is important not to confuse the rowset with the result set. 而在行集中维护应用程序缓冲区中,结果集保留在数据源。The result set is maintained at the data source, while the rowset is maintained in application buffers. 结果集固定的而未将行集-更改位置并且内容每次提取一组新的行。While the result set is fixed, the rowset is not - it changes position and contents each time a new set of rows is fetched. 如对当前行的传统 SQL 只进游标点单行游标,就像块状游标指向行集,可以将看作当前行Just as a single-row cursor such as the traditional SQL forward-only cursor points to a current row, a block cursor points to the rowset, which can be thought of as current rows.

若要执行操作的操作的单个行,已提取的多个行时,应用程序必须首先指示哪些行是当前行。To perform operations that operate on a single row when multiple rows have been fetched, the application must first indicate which row is the current row. 当前行通过调用所需SQLGetData和定位 update 和 delete 语句。The current row is required by calls to SQLGetData and positioned update and delete statements. 当块游标首先返回行集时,当前行是行集的第一个行。When a block cursor first returns a rowset, the current row is the first row of the rowset. 若要更改的当前行中,应用程序调用SQLSetPosSQLBulkOperations (为了按书签更新)。To change the current row, the application calls SQLSetPos or SQLBulkOperations (to update by bookmark). 下图显示了结果集、 行集、 当前行、 行集游标和块状游标的关系。The following illustration shows the relationship of the result set, rowset, current row, rowset cursor, and block cursor. 有关详细信息,请参阅使用块状游标本部分中,将在后面和定位更新和删除语句使用 SQLSetPos 更新数据For more information, see Using Block Cursors, later in this section, and Positioned Update and Delete Statements and Updating Data with SQLSetPos.

接下来,提取之前,第一个和最后一个行集Fetching Next, Prior, First, and Last Rowsets

指示光标是否块状游标不依赖于它是否可滚动。Whether a cursor is a block cursor is independent of whether it is scrollable. 例如,检索和打印的行所用的大部分报表应用程序中工作。For example, most of the work in a report application is spent retrieving and printing rows. 因此,它将最快使用只进、 阻止游标。Because of this, it will work fastest with a forward-only, block cursor. 它使用只进游标来避免可滚动游标和块状游标来减少网络流量的费用。It uses a forward-only cursor to avoid the expense of a scrollable cursor, and a block cursor to reduce the network traffic.

本部分包含以下主题。This section contains the following topics.