Subject RE: [IBO] TIB_DSQL and Active
Author Calin Pirtea
Hi Clive,

Helen is right as always.

TIB_DSQL cannot be used to know if a row was returned or not. Active
true only means the execute statement has fields returned. A DSQL will
always return one row. If it does not it will raise an exception unless
of course it does not return fields in the first place.

Active will always be true if the DSQL should return a row and always
false if the DSQL does not return data.

What you seem to want to do is best achieved with a TIB_Cursor and there
you call EOF to know if one row has been returned.

If your field returns a row and the field might not have a blob in it
maybe all you need is to check for NULL before assigning provided your
DSQL statement will return null.

Cheers,
Calin.


> -----Original Message-----
> From: Helen Borrie
> At 11:29 AM 28/04/2006, you wrote:
> >Here is a code snippet
> >======================
> >if not qryPhotoImg.Prepared then begin
> > qryPhotoImg.Prepare;
> >end;
> >qryPhotoImg.Params[0].Clear;
> >qryPhotoImg.Params[0].AsInteger := Key; qryPhotoImg.Execute; if
> >qryPhotoImg.Active then begin
> > tmpStream := TMemoryStream.Create;
> >TIB_ColumnBlob(qryPhotoImg.FieldByName('IMG_PHOTO')).AssignTo
> (tmpStream);
> > aImgHolder.LoadImg(Key,'',tmpStream);
> >end;
> >========================
> >
> >I want to be sure I have a BLOB before assigning it to a stream.
>
> It doesn't look like a correct usage of an Execute operation
> to me (though you still didn't provide an example).
>
> Seriously, if you are somehow passing a key so you can pull
> over a blob associated with that key, you should use a
> TIB_Cursor and a SELECT statement. Trying to pass blobs in
> SP arguments is fraught with problems architecturally.
>