sql >> Base de Datos >  >> RDS >> Oracle

ClientDataSet TBDCRedondeo de campo

Resolví el problema con otra solución.

type
   TInternalQuery = class(TQuery)
   protected
      procedure InternalInitFieldDefs; override;
   public
      constructor Create(AOwner: TComponent; const qryGen: TQuery); reintroduce;
   end;

constructor TInternalQuery.Create(AOwner: TComponent; const qryGen: TQuery);
var
   intCont: Integer;
begin
   inherited Create(AOwner);
   Self.DatabaseName := qryGen.DatabaseName;
   Self.UpdateObject := qryGen.UpdateObject;

   Self.SQL.Text := qryGen.SQL.Text;

   for intCont := 0 to Self.ParamCount - 1 do
   begin
     Self.Params[intCont].Value := qryGen.Params[intCont].Value;
   end;  
end;

procedure TInternalQuery.InternalInitFieldDefs;
var
   intCont: Integer;
begin
   inherited InternalInitFieldDefs;
   for intCont := 0 to FieldDefs.Count - 1 do
   begin
      if (FieldDefs[intCont].Size = 0) and (FieldDefs[intCont].DataType = ftBCD) then
      begin
         FieldDefs[intCont].Precision := 64;
         FieldDefs[intCont].Size := 32;
      end;  
   end;  
end;

el problema es ((FieldDefs[intCont].Size =0) y (FieldDefs[intCont].DataType =ftBCD)). cuando se crea ClientDataSet, el campo se trunca, porque cuando Oracle tiene una función como "SUM(TOTAL)", el campo de resultado se crea con el tamaño 0, por lo que el conjunto de datos del cliente maneja el campo como un campo Integer.