Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
The original poster asked what the difference was between CLOSE CURSOR and FREE CURSOR in embedded SQL. Paulo Silva, Vic Glass and Khem Chander agreed that CLOSE discards the rows but allows the cursor to be reopened, for a fresh result set, while FREE releases all its memory and prevents reopening. Vic added that a prepared statement must be freed separately. Answered.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
What difference CLOSE cursor between FREE CURSOR?
EXEC SQL close cursor;
EXEC SQL free cursor;
--
------------------------------
e-mail to soph@doit.ajou.ac.kr
↪ replying to soph@engineer.ajou.ac.kr
Paulo Silva — — source: Informix-list mailing list archive (1991-1998)
soph@engineer.ajou.ac.kr wrote:
>
> What difference CLOSE cursor between FREE CURSOR?
>
> EXEC SQL close cursor;
This empties and releases the buffer associated with the cursor, meaning
you discard all the rows, but you can still OPEN the cursor again,
retrieving all matching rows (which can be different than the previous
set, giving some time has ellapsed and the table may have been modified)
> EXEC SQL free cursor;
This one discards any reference to the cursor on both the client and the
server i.e. you release ALL memory associated with this cursor, loosing
the ability to reopen it.
You should use CLOSE+OPEN to 'refresh' your set of rows, and FREE when
you are done.
>
> --
> ------------------------------
> e-mail to soph@doit.ajou.ac.kr
--
_________________________________________________
Paulo Silva mailto:psilva@informix.com
Consultant/Trainer phone : +351 1 412 89 40
Informix Software Portugal fax : +351 1 410 84 37
↪ replying to soph@engineer.ajou.ac.kr
Vic Glass — — source: Informix-list mailing list archive (1991-1998)
Since CLOSE CURSOR and FREE CURSOR are both explained (technically) in
the "Informix Guide to SQL - Syntax", I presume you are looking for some
additionally information.
Use close cursor if you plan to re-open (that is, re-use) the cursor.
You would want to do this for a number of reasons, including (a) you
want to get an a more current picture of the data, (b) your program does
something over and over and you are using a dynamic statement for the
cursor where the selection criteria changes.
Use free cursor if you will not be using the cursor further in your
program, and particularly if your program has a long way to go - freeing
the cursor frees resources associated with the cursor. If you used a
prepared statement to create the cursor, then you will need to free the
prepared statement (via its id) separately.
soph@engineer.ajou.ac.kr wrote:
> What difference CLOSE cursor between FREE CURSOR?
>
> EXEC SQL close cursor;
> EXEC SQL free cursor;
>
> --
> ------------------------------
> e-mail to soph@doit.ajou.ac.kr
↪ replying to soph@engineer.ajou.ac.kr
Khem Chander — — source: Informix-list mailing list archive (1991-1998)
HI Buddy,
close cursor statement only closes the cursor but does not free the
memory allcocated by informix for the cursor. If your program is going to
exit immediately after clost cursor statement then you don't need to worry
about free cursor. But if your program is complicated and has lots of other
processing to do and will run for another couple of minutes or more than it
is a good idea to do free cursor after the close cursor to free the memory.
But make sure you don't need the cursor after that. You won't be able to
open cursor once you have done free.
thanks,
khem chander
kchande@yahoo.com
soph@engineer.ajou.ac.kr wrote in article
<slrn7k45uj.fm2.soph@engineer.ajou.ac.kr>...
>
> What difference CLOSE cursor between FREE CURSOR?
>
> EXEC SQL close cursor;
> EXEC SQL free cursor;
>
> --
> ------------------------------
> e-mail to soph@doit.ajou.ac.kr
>
Your privacy choices
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.