![]() |
|
Use the FREE statement to release resources that are allocated to a prepared statement or to a cursor.
Use this statement with ESQL/C.
The FREE statement releases the resources that the database server and application-development tool allocated for a prepared statement or a declared cursor.
If you prepared a statement (but did not declare a cursor for it), FREE statement_id (or statement_id_var) releases the resources in both the application development tool and the database server.
If you declared a cursor for a prepared statement, FREE statement_id (or statement_id_var) releases only the resources in the application development tool; the cursor can still be used. The resources in the database server are released only when you free the cursor.
After you free a statement, you cannot execute it or declare a cursor for it until you prepare it again.
The following ESQL/C example shows the sequence of statements that is used to free an implicitly prepared statement:
The following ESQL/C example shows the sequence of statements that are used to release the resources of an explicitly prepared statement. The first FREE statement in this example frees the cursor. The second FREE statement in this example frees the prepared statement.
If you declared a cursor for a prepared statement, freeing the cursor releases only the resources in the database server. To release the resources for the statement in the application-development tool, use FREE statement_id (or statement_id_var).
If a cursor is not declared for a prepared statement, freeing the cursor releases the resources in both the application-development tool and the database server.
After a cursor is freed, it cannot be opened until it is declared again. The cursor should be explicitly closed before it is freed.
For an example of a FREE statement that frees a cursor, see the second example in Freeing a Statement.
Related statements: CLOSE, DECLARE, EXECUTE, EXECUTE IMMEDIATE, OPEN, PREPARE, and SET AUTOFREE
For a task-oriented discussion of the FREE statement, see the Informix Guide to SQL: Tutorial.