Subject Re: [IBO] DSQL Executing
Author Svein Erling Tysvær
Hi Yagi,
the thing you're doing "wrong" is to use an IB_DSQL for a SELECT statement.
I didn't know it wouldn't work when returning no rows, but you'll get into
trouble anyway when issuing the IB_DSQL again (due to an error in how IB
(IBO is not guilty :o) handles DSQLs). By using an IB_Cursor you can avoid
any problems.

There's no need to unprepare the IB_Cursor (unless it's a huge program
requiring lots of resources), but with a DSQL you have to unprepare for
each execution. Just use something like (Delphi, not BCB):
if not ibcursorCM.Prepared then ibcursorCM.Prepare;
ibcursorCM.ParamByName("ADRES").AsString:=adres;
ibcursorCM.First;
if ibcursorCM.Eof then <dosomeerrorhandling>

The first line is redundant, since ParamByName prepares the statement if
necessary (but it makes your code easier to read).

HTH (Hope This Helps),
Set

At 13:03 01.03.2001 +0100, you wrote:
>I use TIB_DSQL with te following statement:
>SELECT NUMER
>FROM STANOWISKA
>WHERE NIECZYNNE = 0 AND STANOWISKA.ADRES = :ADRES
>In my source code i'v got something like this
> ibdsqlCM->Prepared = true;
> ibdsqlCM->ParamByName("ADRES")->AsString = adres;
> ibdsqlCM->Execute();
>now, if SELECT statement returns no records (adres parameter is wrong) then
>i got an error on ibdsqlCM.Execute():
>ISC ERROR CODE:335544374
>ISC ERROR MESSAGE:
>attempt to fetch past the last record in a record stream
>Am I doing something wrong?
>2.I set Prepared = true for TIB_DSQL or TIB_StoredProc before setting params.
>Shuld I set Prepared=false after Execute() if i'm going to use another
>parameters value and exec the statement again?
>Thanks for reply
>Yagi