sp_cursorinfo [{<cursor_level> | null}][, <cursor_name>]
<cursor_level> | null
是 SAP ASE 服务器为游标返回信息的级别。可以为 <cursor_level> 指定以下级别:
<N> 在特定过程嵌套级别的存储过程内声明的任何游标。可以为此级别指定任何正数。
若要了解任何游标级别上具有特定 <cursor_name> 的游标,请为此参数指定 null。
<cursor_name>
是游标的特定名称。SAP ASE 服务器报告在指定的 <cursor_level> 上使用该名称的所有活动游标的信息。如果省略了此参数,SAP ASE 服务器将报告该级别上所有游标的信息。
显示级别 0 上名为 c 的游标的信息:
1> declare c cursor
2> for select au_id,au_lname, au_fname from authors
3> go
1> sp_cursorinfo
2> go
Cursor name 'c' is declared at nesting level '0'.
The cursor is declared as NON-SCROLLABLE cursor.
The cursor id is 917505.
The cursor has been successfully opened 0 times.
The cursor will remain open when a transaction is
committed or rolled back.
The number of rows returned for each FETCH is 1.
The cursor is updatable.
This cursor is using 5389 bytes of memory.
(return status = 0)
显示有关游标的可滚动性和敏感性的信息,在本例中为半敏感的可滚动游标 css:
sp_cursorinfo 0, cursor_css
-------------
Cursor name 'css' is declared at nesting level '0'.
The cursor is declared as SEMI_SENSITIVE SCROLLABLE cursor.
The cursor id is 786434.
The cursor has been successfully opened 1 times.
The cursor was compiled at isolation level 1.
The cursor is currently scanning at a nonzero isolation level.
The cursor is positioned on a row.
There have been 1 rows read, 0 rows updated and 0 rows deleted through this
cursor.
The cursor will remain open when a transaction is committed or rolled back.
The number of rows returned for each FETCH is 1.
The cursor is read only.
This cursor is using 19892 bytes of memory.
There are 2 columns returned by this cursor.
The result columns are:
Name = 'c1', Table = 't1', Type = INT, Length = 4 (not updatable)
Name = 'c2', Table = 't1', Type = INT, Length = 4 (not updatable)
使用 sp_cursorinfo 时,还存在一些其它注意事项:
如果未指定 <cursor_level> 或 <cursor_name> 中的一个,SAP ASE 服务器将显示所有活动游标的信息。活动游标是由用户声明并由 SAP ASE 服务器分配的游标。
SAP ASE 服务器报告每个游标的以下信息:
根据游标的状态,sp_cursorinfo 的输出有所不同。除了列出的信息之外,sp_cursorinfo 还显示游标的 showplan 输出。