ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBArray.pas
(Generate patch)

Comparing:
ibx/trunk/fbintf/client/FBArray.pas (file contents), Revision 315 by tony, Thu Feb 25 11:56:36 2021 UTC vs.
ibx/branches/udr/client/FBArray.pas (file contents), Revision 379 by tony, Mon Jan 10 10:08:03 2022 UTC

# Line 101 | Line 101 | type
101     procedure SetAsFloat(Value: Float); override;
102     procedure SetAsCurrency(Value: Currency); override;
103     procedure SetAsBcd(aValue: tBCD); override;
104 +   procedure SetAsNumeric(Value: IFBNumeric); override;
105    end;
106  
107    { TFBArrayMetaData }
# Line 246 | Line 247 | type
247  
248   implementation
249  
250 < uses FBMessages;
250 > uses FBMessages, IBUtils, FBNumeric;
251  
252   { TFBArrayElement }
253  
# Line 366 | Line 367 | begin
367    CheckActive;
368    case GetSQLType of
369    SQL_LONG:
370 <    PLong(SQLData)^ := Value;
370 >    PLong(SQLData)^ := NumericFromRawValues(Value,getScale).getRawValue;
371    SQL_SHORT:
372 <    PShort(SQLData)^ := Value;
372 >    PShort(SQLData)^ := NumericFromRawValues(Value,getScale).getRawValue;
373    SQL_INT64:
374 <    PInt64(SQLData)^ := Value;
374 >    PInt64(SQLData)^ := NumericFromRawValues(Value,getScale).getRawValue;
375    SQL_TEXT, SQL_VARYING:
376      SetAsString(IntToStr(Value));
377    SQL_D_FLOAT,
# Line 387 | Line 388 | end;
388   procedure TFBArrayElement.SetAsString(Value: AnsiString);
389   var len: integer;
390      ElementSize: integer;
391 +    Int64Value: Int64;
392 +    aScale: integer;
393   begin
394    CheckActive;
395    case GetSQLType of
# Line 427 | Line 430 | begin
430    SQL_SHORT,
431    SQL_LONG,
432    SQL_INT64:
433 <    if trim(Value) = '' then
434 <      SetAsInt64(0)
433 >    if TryStrToNumeric(Value,Int64Value,aScale) then
434 >      SetAsNumeric(NumericFromRawValues(Int64Value,aScale))
435      else
436 <      SetAsInt64(AdjustScaleFromCurrency(StrToCurr(Value),GetScale));
436 >      SetAsCurrency(StrToCurr(Value));
437  
438    SQL_D_FLOAT,
439    SQL_DOUBLE,
440    SQL_FLOAT:
441 <  if trim(Value) = '' then
442 <    SetAsDouble(0)
443 <  else
444 <    SetAsDouble(StrToFloat(Value));
441 >    if TryStrToNumeric(Value,Int64Value,aScale) then
442 >      SetAsDouble(NumericToDouble(Int64Value,AScale))
443 >    else
444 >      IBError(ibxeInvalidDataConversion,[nil]);
445 >
446 >  SQL_DEC_FIXED,
447 >  SQL_DEC16,
448 >  SQL_DEC34,
449 >  SQL_INT128:
450 >    SetAsBCD(StrToBCD(Value));
451  
452    SQL_TIMESTAMP:
453      SetAsDateTime(StrToDateTime(Value));
# Line 465 | Line 474 | begin
474      PSingle(SQLData)^ := Value;
475    SQL_SHORT:
476      if Scale < 0 then
477 <      PShort(SQLData)^ := AdjustScaleFromDouble(Value,Scale)
477 >      PShort(SQLData)^ := SafeSmallInt(NewNumeric(Value,Scale).getRawValue)
478      else
479        IBError(ibxeInvalidDataConversion, [nil]);
480    SQL_LONG:
481      if Scale < 0 then
482 <      PLong(SQLData)^ := AdjustScaleFromDouble(Value,Scale)
482 >      PLong(SQLData)^ := SafeInteger(NewNumeric(Value,Scale).getRawValue)
483      else
484        IBError(ibxeInvalidDataConversion, [nil]);
485    SQL_INT64:
486      if Scale < 0 then
487 <      PInt64(SQLData)^ := AdjustScaleFromDouble(Value,Scale)
487 >      PInt64(SQLData)^ := NewNumeric(Value,Scale).getRawValue
488      else
489        IBError(ibxeInvalidDataConversion, [nil]);
490    SQL_TEXT, SQL_VARYING:
# Line 501 | Line 510 | begin
510      if Scale = -4 then
511        PCurrency(SQLData)^ := Value
512      else
513 <      PInt64(SQLData)^ := AdjustScaleFromCurrency(Value,Scale);
513 >      PInt64(SQLData)^ := NewNumeric(Value).clone(Scale).getRawValue;
514      Changed;
515    end
516   end;
# Line 529 | Line 538 | begin
538    Changed;
539   end;
540  
541 + procedure TFBArrayElement.SetAsNumeric(Value: IFBNumeric);
542 + begin
543 +  CheckActive;
544 +  case GetSQLType of
545 +  SQL_LONG:
546 +      PLong(SQLData)^ := SafeInteger(Value.clone(Scale).getRawValue);
547 +  SQL_SHORT:
548 +    PShort(SQLData)^ := SafeSmallInt(Value.clone(Scale).getRawValue);
549 +  SQL_INT64:
550 +    PInt64(SQLData)^ := Value.clone(Scale).getRawValue;
551 +  SQL_TEXT, SQL_VARYING:
552 +   SetAsString(Value.getAsString);
553 +  SQL_D_FLOAT,
554 +  SQL_DOUBLE:
555 +    PDouble(SQLData)^ := Value.getAsDouble;
556 +  SQL_FLOAT:
557 +    PSingle(SQLData)^ := Value.getAsDouble;
558 +  else
559 +    IBError(ibxeInvalidDataConversion, [nil]);
560 +  end;
561 +  Changed;
562 + end;
563 +
564   procedure TFBArrayElement.SetSQLType(aValue: cardinal);
565   begin
566    if aValue <> GetSQLType then
# Line 790 | Line 822 | begin
822    InternalPutSlice(Force);
823    FModified := false;
824    FIsNew := false;
825 +  FLoaded := true;
826   end;
827  
828   function TFBArray.GetOffset(index: array of integer): PByte;

Comparing:
ibx/trunk/fbintf/client/FBArray.pas (property svn:eol-style), Revision 315 by tony, Thu Feb 25 11:56:36 2021 UTC vs.
ibx/branches/udr/client/FBArray.pas (property svn:eol-style), Revision 379 by tony, Mon Jan 10 10:08:03 2022 UTC

# Line 0 | Line 1
1 + native

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines