Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Using Procedures, Triggers, and Batches » Using cursors in procedures and triggers

Using cursors in procedures and triggers Next Page

Cursor management overview


Managing a cursor is similar to managing a file in a programming language. The following steps manage cursors:

  1. Declare a cursor for a particular SELECT statement or procedure using the DECLARE statement.

  2. Open the cursor using the OPEN statement.

  3. Use the FETCH statement to retrieve results one row at a time from the cursor.

  4. The warning Row Not Found signals the end of the result set.

  5. Close the cursor using the CLOSE statement.

By default, cursors are automatically closed at the end of a transaction (on COMMIT or ROLLBACK statements). Cursors opened using the WITH HOLD clause will stay open for subsequent transactions until explicitly closed.

For more information on positioning cursors, see Cursor positioning.