#1 2011-10-19 10:32:52

Sir Rufo
Member
Registered: 2011-10-14
Posts: 24

TSQLRecord.FillOne raises Exception

The normal way to retrieve some records is this, which is quite clear and handsome

if MyRecord.FillPrepare( MyClient, 'IntData=?', [], [1] ) then
  while MyRecord.FillOne do
  begin
    // do something very important
  end;

But if we get no result from FillPrepare we will get an Exception from FillOne

// Fill with definitive no Rows just for testing
if MyRecord.FillPrepare( MyClient, '1=0', [], [] ) then // is true because the statement is correct
  while MyRecord.FillOne do  // <-- here we get an exception
  begin
    // do something very important
  end;

Is this behavior a feature?
The fix is really simple to do

function TSQLRecord.FillOne: boolean;
begin
  if (self=nil) or (fFill=nil) or (fFill.Table=nil) or 
     (fFill.Table.RowCount=0) or // <-- also check if FillTable is emtpy
     (cardinal(fFill.FillCurrentRow)>cardinal(fFill.Table.RowCount)) then
    result := false else begin
    FillRow(fFill.FillCurrentRow);
    inc(fFill.FillCurrentRow);
    result := true;
  end;
end;

Offline

#2 2011-10-19 14:58:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: TSQLRecord.FillOne raises Exception

I think this is a failure, not a feature. wink

I've added your fix in http://synopse.info/fossil/info/967c1cb0dc

Thanks for the report and the associated fix!

Offline

Board footer

Powered by FluxBB