Page 1 of 1

[patch_done] Another Patch for ZConnection

Posted: 15.05.2009, 11:22
by Ostfriese
Currently the Delphi compiler throws a hint that the assigned return value for ExecuteDirect is never used.

By modifying

Code: Select all

function TZConnection.ExecuteDirect(SQL:string; var RowsAffected:integer):boolean;
var
  stmt : IZStatement;
begin
  result := False;
  CheckConnected;
  stmt := DbcConnection.CreateStatement;
  RowsAffected:= stmt.ExecuteUpdate(SQL);
  result := (RowsAffected <> -1);
  stmt:=nil;
end;
to

Code: Select all

function TZConnection.ExecuteDirect(SQL:string; var RowsAffected:integer):boolean;
var
  stmt : IZStatement;
begin
  //HA 090515 remove compiler hint ..
  //result := False;
  //CheckConnected;
  //stmt := DbcConnection.CreateStatement;
  //RowsAffected:= stmt.ExecuteUpdate(SQL);
  //result := (RowsAffected <> -1);
  //stmt:=nil;
  //..
  try
    try
      CheckConnected;
      stmt := DbcConnection.CreateStatement;
      RowsAffected:= stmt.ExecuteUpdate(SQL);
      result := (RowsAffected <> -1);
    except
      RowsAffected := -1;
      result := False;
    end;
  finally
    stmt:=nil;
  end;
end;
this hint can be removed and the function is IMHO aditionaly more fail-save

Re: Another Patch for ZConnection

Posted: 15.05.2009, 11:58
by gto
Ostfriese wrote:Currently the Delphi compiler throws a hint that the assigned return value for ExecuteDirect is never used.

By modifying

Code: Select all

function TZConnection.ExecuteDirect(SQL:string; var RowsAffected:integer):boolean;
var
  stmt : IZStatement;
begin
  result := False;
  CheckConnected;
  stmt := DbcConnection.CreateStatement;
  RowsAffected:= stmt.ExecuteUpdate(SQL);
  result := (RowsAffected <> -1);
  stmt:=nil;
end;
to

Code: Select all

function TZConnection.ExecuteDirect(SQL:string; var RowsAffected:integer):boolean;
var
  stmt : IZStatement;
begin
  //HA 090515 remove compiler hint ..
  //result := False;
  //CheckConnected;
  //stmt := DbcConnection.CreateStatement;
  //RowsAffected:= stmt.ExecuteUpdate(SQL);
  //result := (RowsAffected <> -1);
  //stmt:=nil;
  //..
  try
    try
      CheckConnected;
      stmt := DbcConnection.CreateStatement;
      RowsAffected:= stmt.ExecuteUpdate(SQL);
      result := (RowsAffected <> -1);
    except
      RowsAffected := -1;
      result := False;
    end;
  finally
    stmt:=nil;
  end;
end;
this hint can be removed and the function is IMHO aditionaly more fail-save
Good patch :)
Totally agreed

Posted: 15.05.2009, 12:42
by Ostfriese
Thanks 8)

Posted: 18.05.2009, 23:57
by mdaems
gto,
You've got SVN commit rights, you can use them to apply this kind of patches ;)
Don't forget to update the changes.xml file in the documentation directory.

Ostfriese,
SVN rev. 643

Mark