Subject | RE: [IBO] check for empty dataset |
---|---|
Author | Jason Wharton |
Post date | 2004-07-28T20:43:04Z |
The code provided there is correct for what is being requested. It just
needs to include code to Close it as well. Preferably in a try...finally
protection block.
Technically, you do open cursors and close them. If you are calling Execute
chances are (I would have to confirm) I am recognizing that you are working
with a SELECT statement (via StatementType info) and Open it for you. What
Helen is trying to say is you are not going to have an opened/buffered
result set. You may only work with a single record at a time since the
IB_Cursor component doesn't buffer the records. However, to merely determine
if a select statement will return records and you are using the cursor
component it is appropriate that you both open it and attempt to fetch one
record. You will either get a record or Eof as true. Calling the TIB_Cursor
First method will do this for you and then you just check the Eof property
whether it is true or not and then be sure to Close the cursor.
Jason Wharton
-----Original Message-----
From: Helen Borrie [mailto:helebor@...]
Sent: Tuesday, July 27, 2004 4:51 PM
To: IBObjects@yahoogroups.com
Subject: RE: [IBO] check for empty dataset
At 08:20 PM 27/07/2004 +0000, Ronan van Riet wrote:
unbuffered. Execute is OK if you are using an ib_cursor to execute a DML
statement, including an executable SP that returns a single set of return
values. For ib_cursors on SELECT statements, always call First to begin
fetching.
needs to include code to Close it as well. Preferably in a try...finally
protection block.
Technically, you do open cursors and close them. If you are calling Execute
chances are (I would have to confirm) I am recognizing that you are working
with a SELECT statement (via StatementType info) and Open it for you. What
Helen is trying to say is you are not going to have an opened/buffered
result set. You may only work with a single record at a time since the
IB_Cursor component doesn't buffer the records. However, to merely determine
if a select statement will return records and you are using the cursor
component it is appropriate that you both open it and attempt to fetch one
record. You will either get a record or Eof as true. Calling the TIB_Cursor
First method will do this for you and then you just check the Eof property
whether it is true or not and then be sure to Close the cursor.
Jason Wharton
-----Original Message-----
From: Helen Borrie [mailto:helebor@...]
Sent: Tuesday, July 27, 2004 4:51 PM
To: IBObjects@yahoogroups.com
Subject: RE: [IBO] check for empty dataset
At 08:20 PM 27/07/2004 +0000, Ronan van Riet wrote:
>Thanks Paul for your reply!You don't open and close datasets formed by ib_cursors, because they are
>
>Is it necessary to close the IB_Cursor before preparing it?
>I am executing the IB_Cursor, rather than opening it. What is the
>difference?
unbuffered. Execute is OK if you are using an ib_cursor to execute a DML
statement, including an executable SP that returns a single set of return
values. For ib_cursors on SELECT statements, always call First to begin
fetching.
> > if not MyCursor.Prepared then MyCursor.Prepare;Helen
> > // don't Open a cursor; (API)First will "open" it:
> > MyCursor.First; // or, faster:
> APIFirst <<<--------------------------------------
> > if MyCursor.Eof
> > then ... // dataset was empty
> > else ... // dataset contains at least one record