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

Comparing ibx/trunk/fbintf/client/FBArray.pas (file contents):
Revision 349 by tony, Mon Oct 18 08:39:40 2021 UTC vs.
Revision 353 by tony, Sat Oct 23 14:11:37 2021 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: Int64; aScale: integer); override;
105    end;
106  
107    { TFBArrayMetaData }
# Line 246 | Line 247 | type
247  
248   implementation
249  
250 < uses FBMessages;
250 > uses FBMessages, IBUtils;
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)^ := AdjustScaleToInt64(Value,getScale);
371    SQL_SHORT:
372 <    PShort(SQLData)^ := Value;
372 >    PShort(SQLData)^ := AdjustScaleToInt64(Value,getScale);
373    SQL_INT64:
374 <    PInt64(SQLData)^ := Value;
374 >    PInt64(SQLData)^ := AdjustScaleToInt64(Value,getScale);
375    SQL_TEXT, SQL_VARYING:
376      SetAsString(IntToStr(Value));
377    SQL_D_FLOAT,
# Line 388 | Line 389 | procedure TFBArrayElement.SetAsString(Va
389   var len: integer;
390      ElementSize: integer;
391      Int64Value: Int64;
392 +    aScale: integer;
393   begin
394    CheckActive;
395    case GetSQLType of
# Line 428 | Line 430 | begin
430    SQL_SHORT,
431    SQL_LONG,
432    SQL_INT64:
433 <    if trim(Value) = '' then
434 <      SetAsInt64(0)
433 <    else
434 <    if TryStrToInt64(Value,Int64Value) then
435 <      SetAsInt64(Int64Value)
433 >    if TryStrToNumeric(Value,Int64Value,aScale) then
434 >      SetAsNumeric(Int64Value,AScale)
435      else
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 532 | Line 537 | begin
537    end;
538    Changed;
539   end;
540 +
541 + procedure TFBArrayElement.SetAsNumeric(Value: Int64; aScale: integer);
542 + begin
543 +  CheckActive;
544 +  case GetSQLType of
545 +  SQL_LONG:
546 +    PLong(SQLData)^ := AdjustScaleToInt64(Value,aScale - getScale);
547 +  SQL_SHORT:
548 +    PShort(SQLData)^ := AdjustScaleToInt64(Value,aScale - getScale);
549 +  SQL_INT64:
550 +    PInt64(SQLData)^ := AdjustScaleToInt64(Value,aScale - getScale);
551 +  SQL_TEXT, SQL_VARYING:
552 +   SetAsString(AdjustScaleToStr(Value,aScale));
553 +  SQL_D_FLOAT,
554 +  SQL_DOUBLE:
555 +    PDouble(SQLData)^ := AdjustScale(Value,aScale);
556 +  SQL_FLOAT:
557 +    PSingle(SQLData)^ := AdjustScale(Value,aScale);
558 +  else
559 +    IBError(ibxeInvalidDataConversion, [nil]);
560 +  end;
561 +  Changed;
562 + end;
563  
564   procedure TFBArrayElement.SetSQLType(aValue: cardinal);
565   begin

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines