ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBCustomDataSet.pas
(Generate patch)

Comparing ibx/trunk/runtime/IBCustomDataSet.pas (file contents):
Revision 104 by tony, Thu Jan 18 14:37:29 2018 UTC vs.
Revision 106 by tony, Thu Jan 18 14:37:35 2018 UTC

# Line 2074 | Line 2074 | procedure TIBCustomDataSet.ColumnDataToB
2074                 ColumnIndex, FieldIndex: integer; Buffer: PChar);
2075   var
2076    LocalData: PByte;
2077 <  LocalDate, LocalDouble: Double;
2077 >  LocalDate: TDateTime;
2078 >  LocalDouble: Double;
2079    LocalInt: Integer;
2080    LocalBool: wordBool;
2081    LocalInt64: Int64;
2082    LocalCurrency: Currency;
2082  p: PRecordData;
2083    ColData: ISQLData;
2084   begin
2085  p := PRecordData(Buffer);
2085    LocalData := nil;
2086 <  with p^.rdFields[FieldIndex], FFieldColumns^[FieldIndex] do
2086 >  with PRecordData(Buffer)^.rdFields[FieldIndex], FFieldColumns^[FieldIndex] do
2087    begin
2088      QryResults.GetData(ColumnIndex,fdIsNull,fdDataLength,LocalData);
2089      if not fdIsNull then
2090      begin
2091        ColData := QryResults[ColumnIndex];
2092        case fdDataType of  {Get Formatted data for column types that need formatting}
2093 +        SQL_TYPE_DATE,
2094 +        SQL_TYPE_TIME,
2095          SQL_TIMESTAMP:
2096          begin
2097 <          LocalDate := TimeStampToMSecs(DateTimeToTimeStamp(ColData.AsDateTime));
2097 >          {This is an IBX native format and not the TDataset approach. See also GetFieldData}
2098 >          LocalDate := ColData.AsDateTime;
2099            LocalData := PByte(@LocalDate);
2100          end;
2099        SQL_TYPE_DATE:
2100        begin
2101          LocalInt := DateTimeToTimeStamp(ColData.AsDateTime).Date;
2102          LocalData := PByte(@LocalInt);
2103        end;
2104        SQL_TYPE_TIME:
2105        begin
2106          LocalInt := DateTimeToTimeStamp(ColData.AsDateTime).Time;
2107          LocalData := PByte(@LocalInt);
2108        end;
2101          SQL_SHORT, SQL_LONG:
2102          begin
2103            if (fdDataScale = 0) then
# Line 2831 | Line 2823 | begin
2823              end;
2824              SQL_BLOB, SQL_ARRAY, SQL_QUAD:
2825                Param.AsQuad := PISC_QUAD(data)^;
2826 <            SQL_TYPE_DATE:
2827 <            begin
2836 <              ts.Date := PInt(data)^;
2837 <              ts.Time := 0;
2838 <              Param.AsDate := TimeStampToDateTime(ts);
2839 <            end;
2840 <            SQL_TYPE_TIME:
2841 <            begin
2842 <              ts.Date := 0;
2843 <              ts.Time := PInt(data)^;
2844 <              Param.AsTime := TimeStampToDateTime(ts);
2845 <            end;
2826 >            SQL_TYPE_DATE,
2827 >            SQL_TYPE_TIME,
2828              SQL_TIMESTAMP:
2829 <              Param.AsDateTime :=
2830 <                       TimeStampToDateTime(MSecsToTimeStamp(trunc(PDouble(data)^)));
2829 >            {This is an IBX native format and not the TDataset approach. See also SetFieldData}
2830 >              Param.AsDateTime := PDateTime(data)^;
2831              SQL_BOOLEAN:
2832                Param.AsBoolean := PWordBool(data)^;
2833            end;
# Line 4172 | Line 4154 | begin
4154      for i := 0 to SQLParams.GetCount - 1 do
4155      begin
4156        cur_field := DataSource.DataSet.FindField(SQLParams[i].Name);
4157 <      cur_param := SQLParams[i];
4158 <      if (cur_field <> nil) then begin
4157 >      if (cur_field <> nil) then
4158 >      begin
4159 >        cur_param := SQLParams[i];
4160          if (cur_field.IsNull) then
4161            cur_param.IsNull := True
4162 <        else case cur_field.DataType of
4162 >        else
4163 >        case cur_field.DataType of
4164            ftString:
4165              cur_param.AsString := cur_field.AsString;
4166            ftBoolean:
# Line 4186 | Line 4170 | begin
4170            ftInteger:
4171              cur_param.AsLong := cur_field.AsInteger;
4172            ftLargeInt:
4173 <            cur_param.AsInt64 := TLargeIntField(cur_field).AsLargeInt;
4173 >            cur_param.AsInt64 := cur_field.AsLargeInt;
4174            ftFloat, ftCurrency:
4175             cur_param.AsDouble := cur_field.AsFloat;
4176            ftBCD:
# Line 4940 | Line 4924 | end;
4924   function TIBCustomDataSet.GetFieldData(Field: TField; Buffer: Pointer;
4925    NativeFormat: Boolean): Boolean;
4926   begin
4927 <  if (Field.DataType = ftBCD) and not NativeFormat then
4927 >  {These datatypes use IBX conventions and not TDataset conventions}
4928 >  if (Field.DataType in [ftBCD,ftDateTime,ftDate,ftTime]) and not NativeFormat then
4929      Result := InternalGetFieldData(Field, Buffer)
4930    else
4931      Result := inherited GetFieldData(Field, Buffer, NativeFormat);
# Line 4966 | Line 4951 | end;
4951   procedure TIBCustomDataSet.SetFieldData(Field: TField; Buffer: Pointer;
4952    NativeFormat: Boolean);
4953   begin
4954 <  if (not NativeFormat) and (Field.DataType = ftBCD) then
4954 >  {These datatypes use IBX conventions and not TDataset conventions}
4955 >  if (not NativeFormat) and (Field.DataType in [ftBCD,ftDateTime,ftDate,ftTime]) then
4956      InternalSetfieldData(Field, Buffer)
4957    else
4958      inherited SetFieldData(Field, buffer, NativeFormat);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines