I'm starting to believe that my predecessor doesn't exactly know what he was doing...

I'm starting to believe that my predecessor doesn't exactly know what he was doing... 

function ReadFromDatabase(P_1, P_2: integer) : boolean;
var
  Query: TQuery;
begin
  Result := false;
  Query := getQuery();
  
  if ( Query = nil ) then
    exit;

  try
    Query.ParamByName('P_01').AsCurrency := P_1;
    Query.ParamByName('P_02').AsCurrency := P_2;
    Query.Open();
    Query.First();
    Result := true;
  finally
   if ( Query <> nil ) then
    begin
      Query.Close();
      Query.Free();
    end;
  end;
end;

Comments

  1. There's no limit to how bad things can get :)

    ReplyDelete
  2. But there is no check to see if a result set was returned... it might be an empty result set

    ReplyDelete
  3. Well, at least there's no FreeAndNil anywhere... Nick Hodges

    ReplyDelete

Post a Comment