When a cursor is automatically freed, its associated prepared statement (or associated statement) is also freed.
The term associated statement has a special meaning in the context of the Autofree feature. A cursor is associated with a prepared statement if it is the first cursor that you declare with the prepared statement, or if it is the first cursor that you declare with the statement after the statement is detached.
The term detached statement has a special meaning in the context of the Autofree feature. A prepared statement is detached if you do not declare a cursor with the statement, or if the cursor with which the statement is associated was freed.
If the Autofree feature is enabled for a cursor that has an associated prepared statement, and that cursor is closed, the database server frees the memory allocated to the prepared statement as well as the memory allocated for the cursor. Suppose that you enable the Autofree feature for the following cursor:
/*Cursor associated with a prepared statement */ EXEC SQL prepare sel_stmt 'select * from customer'; EXEC SQL declare sel_curs2 cursor for sel_stmt;
When the database server closes the sel_curs2 cursor, it automatically performs the equivalent of the following FREE statements:
FREE sel_curs2; FREE sel_stmt;
Because memory for the sel_stmt statement is freed automatically, you cannot declare a new cursor on it unless you prepare the statement again.
Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]