Subject Re: [firebird-support] isc_dsql_free_statement
Author Ivan Prenosil
"Geoff Worboys" wrote:
> Can anyone clarify for me the rules for when
> isc_dsql_free_statement should be called with DSQL_close.
>
> The old IB6 API doco says only when isc_dsql_set_cursor_name
> has been used, but this does not seem accurate. It seems to
> also be required in other instances even when I have not
> required a cursor name but still want to reuse a statement
> without another prepare.

isc_dsql_set_cursor_name() just gives the cursor a name,
so you can subsequently use commands like
UPDATE ... WHERE CURRENT OF MyCursor;
DELETE FROM ... WHERE CURRENT OF MyCursor;

You call isc_dsql_free_statement() with DSQL_close if you want to reuse
statement handle for another command, or if you want to exectue the same statement
again without fetching whole result.

E.g. you either
- allocate statement
- prepare sql (select) command
- execute it
- fetch result in loop
- when you are done you free statement (using DSQL_free)

But you can also
- allocate statement
- prepare sql (select) command
- execute it
- fetch result in loop
- close the cursor (using DSQL_close)
- execute the statement again, or
- prepare another select command using the same stmt handle
- etc....

Ivan
http://www.volny.cz/iprenosil/interbase/