Hi All, I am new here
currently I m working on mssql database for logging using Linux freetds, sqldb.
Some how I got error when querying large data set
when network error or connection is kill, the process become almost 100% and app doesnt quit
so trace to this code I found that dbnextrow return 0 which equal FAIL
but in this code no handling for exit
function TMSSQLConnection.Fetch(cursor: TSQLCursor): boolean;
begin
// Compute rows resulting from the COMPUTE clause are not processed
repeat
Fstatus := dbnextrow(FDBProc);
Result := Fstatus=REG_ROW;
until Result or (Fstatus = NO_MORE_ROWS); /// this make loop forever
if Fstatus = NO_MORE_ROWS then
while dbresults(FDBProc) <> NO_MORE_RESULTS do // process remaining results if there are any
repeat until dbnextrow(FDBProc) = NO_MORE_ROWS;
end;
because I new here dunno how to make it fix or anybody could check it too?
my current fixed is this
function TMSSQLConnection.Fetch(cursor: TSQLCursor): Boolean;
begin
// Compute rows resulting from the COMPUTE clause are not processed
repeat
Fstatus := dbnextrow(FDBProc);
Result := Fstatus = REG_ROW;
until Result or (Fstatus = NO_MORE_ROWS)
or (FStatus = FAIL); if Fstatus = NO_MORE_ROWS then
while dbresults(FDBProc) <> NO_MORE_RESULTS do // process remaining results if there are any
repeat
FStatus := dbnextrow(FDBProc);
until (FStatus = NO_MORE_ROWS) or (FStatus = FAIL);
if FStatus = FAIL then
CheckError( dbresults(FDBProc) ); end;
probably not best fix