Subject [IBO] Re: TIB_Cursor not returning correct result
Author sgharp
--- In IBObjects@yahoogroups.com, Lucas Franzen <luc@r...> wrote:
>
> Steve,
>
> > I've tried it in a seperate transaction or in the same. I've
also
> > tried TIB_Cursor and TIB_Query and both have the same result.
>
> Before starting to guess can you show us the whole procedure code?
>

Sure.

procedure TDMFb.UpdateAveIdealUsage(const sItem : String);
Var
iInvItemID : Integer;
qry : TIB_Query;
Begin
iInvItemID := DMFb.GetInvItemID(sItem);
if (iInvItemID <> 0) then
Begin
qry := TIB_Query.Create(Self);
Try
qry.IB_Connection := conIx;
qry.IB_Transaction := trnIx;
qry.DatabaseName := 'IxFB';
qry.SQL.Add('Select QtySold From xItemUsages');
qry.SQL.Add('Where InvItemID = ' + IntToStr(iInvItemID));
qry.Open;
qry.First;

// #todo1 Not Working - Returns 0 for QtySold
if (not qry.FieldByName('QtySold').IsNull) then
Begin
DMFb.spUpdateAveIdealUsage.ParamByName
('pInvItemID').AsInteger := iInvItemID;
DMFb.spUpdateAveIdealUsage.ParamByName
('pUsage').AsFloat := qry.FieldByName('QtySold').AsFloat;
DMFb.spUpdateAveIdealUsage.ExecSQL;
End;
Finally
qry.Close;
FreeAndNil(qry);
End;
End;
End;

Note that IBExpert returns the correct value with exactly the same
query.

Steve