Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
To use a cursor in ADO.NET, ODBC, JDBC, or Open Client, follow these general steps:
Prepare and execute a statement.
Execute a statement using the usual method for the interface. You can prepare and then execute the statement, or you can execute the statement directly.
With ADO.NET, only the SACommand.ExecuteReader method returns a cursor. It provides a read-only, forward-only cursor.
Test to see if the statement returns a result set.
A cursor is implicitly opened when a statement that creates a result set is executed. When the cursor is opened, it is positioned before the first row of the result set.
Although simple fetch operations move the cursor to the next row in the result set, SQL Anywhere permits more complicated movement around the result set.
Close the cursor.
When you have finished with the cursor, close it to free associated resources.
Free the statement.
If you used a prepared statement, free it to reclaim memory.
The approach for using a cursor in embedded SQL differs from the approach used in other interfaces. Follow these general steps to use a cursor in embedded SQL:
Prepare a statement.
Cursors generally use a statement handle rather than a string. You need to prepare a statement to have a handle available.
Declare the cursor.
Each cursor refers to a single SELECT or CALL statement. When you declare a cursor, you state the name of the cursor and the statement it refers to.
Open the cursor.
For a CALL statement, opening the cursor executes the procedure up to the point where the first row is about to be obtained.
Although simple fetch operations move the cursor to the next row in the result set, SQL Anywhere permits more complicated movement around the result set. How you declare the cursor determines which fetch operations are available to you.
Close the cursor.
When you have finished with the cursor, close it. This frees any resources associated with the cursor.
Drop the statement.
To free the memory associated with the statement, you must drop the statement.
Cursor behavior when opening cursors
Row fetching through a cursor
Cursors used to modify rows
Cursor operations that are canceled
Discuss this page in DocCommentXchange.
|Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0|