[patch_done] Another Patch for ZConnection

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
Ostfriese
Junior Boarder
Junior Boarder
Posts: 25
Joined: 12.05.2009, 10:48
Location: Coburg
Contact:

[patch_done] Another Patch for ZConnection

Post 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
Thomas Jefferson wrote:Information ist die Währung der Demokratie
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Re: Another Patch for ZConnection

Post 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
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
Ostfriese
Junior Boarder
Junior Boarder
Posts: 25
Joined: 12.05.2009, 10:48
Location: Coburg
Contact:

Post by Ostfriese »

Thanks 8)
Thomas Jefferson wrote:Information ist die Währung der Demokratie
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Post Reply