122 |
|
private |
123 |
|
FFirebirdClientAPI: TFBClientAPI; |
124 |
|
FTimeZoneServices: IExTimeZoneServices; |
125 |
– |
function AdjustScale(Value: Int64; aScale: Integer): Double; |
126 |
– |
function AdjustScaleToInt64(Value: Int64; aScale: Integer): Int64; |
127 |
– |
function AdjustScaleToCurrency(Value: Int64; aScale: Integer): Currency; |
125 |
|
function GetDateFormatStr(IncludeTime: boolean): AnsiString; |
126 |
|
function GetTimeFormatStr: AnsiString; |
127 |
|
function GetTimestampFormatStr: AnsiString; |
129 |
|
procedure InternalGetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; |
130 |
|
var aTimezone: AnsiString; var aTimeZoneID: TFBTimeZoneID); |
131 |
|
protected |
132 |
+ |
function AdjustScale(Value: Int64; aScale: Integer): Double; |
133 |
+ |
function AdjustScaleToInt64(Value: Int64; aScale: Integer): Int64; |
134 |
+ |
function AdjustScaleToStr(Value: Int64; aScale: Integer): AnsiString; |
135 |
+ |
function AdjustScaleToCurrency(Value: Int64; aScale: Integer): Currency; |
136 |
|
function AdjustScaleFromCurrency(Value: Currency; aScale: Integer): Int64; |
137 |
|
function AdjustScaleFromDouble(Value: Double; aScale: Integer): Int64; |
138 |
|
procedure CheckActive; virtual; |
206 |
|
procedure SetAsShort(Value: short); virtual; |
207 |
|
procedure SetAsString(Value: AnsiString); virtual; |
208 |
|
procedure SetAsVariant(Value: Variant); |
209 |
< |
procedure SetAsNumeric(Value: Int64; aScale: integer); |
209 |
> |
procedure SetAsNumeric(Value: Int64; aScale: integer); virtual; |
210 |
|
procedure SetAsBcd(aValue: tBCD); virtual; |
211 |
|
procedure SetIsNull(Value: Boolean); virtual; |
212 |
|
procedure SetIsNullable(Value: Boolean); virtual; |
907 |
|
result := Val; |
908 |
|
end; |
909 |
|
|
910 |
+ |
function TSQLDataItem.AdjustScaleToStr(Value: Int64; aScale: Integer |
911 |
+ |
): AnsiString; |
912 |
+ |
var Scaling : AnsiString; |
913 |
+ |
i: Integer; |
914 |
+ |
begin |
915 |
+ |
Result := IntToStr(Value); |
916 |
+ |
Scaling := ''; |
917 |
+ |
if aScale > 0 then |
918 |
+ |
begin |
919 |
+ |
for i := 1 to aScale do |
920 |
+ |
Result := Result + '0'; |
921 |
+ |
end |
922 |
+ |
else |
923 |
+ |
if aScale < 0 then |
924 |
+ |
{$IF declared(DefaultFormatSettings)} |
925 |
+ |
with DefaultFormatSettings do |
926 |
+ |
{$ELSE} |
927 |
+ |
{$IF declared(FormatSettings)} |
928 |
+ |
with FormatSettings do |
929 |
+ |
{$IFEND} |
930 |
+ |
{$IFEND} |
931 |
+ |
begin |
932 |
+ |
if Length(Result) > -aScale then |
933 |
+ |
system.Insert(DecimalSeparator,Result,Length(Result) + aScale) |
934 |
+ |
else |
935 |
+ |
begin |
936 |
+ |
Scaling := '0' + DecimalSeparator; |
937 |
+ |
for i := -1 downto aScale + Length(Result) do |
938 |
+ |
Scaling := Scaling + '0'; |
939 |
+ |
Result := Scaling + Result; |
940 |
+ |
end; |
941 |
+ |
end; |
942 |
+ |
end; |
943 |
+ |
|
944 |
|
function TSQLDataItem.AdjustScaleToCurrency(Value: Int64; aScale: Integer |
945 |
|
): Currency; |
946 |
|
var |
2457 |
|
Changed; |
2458 |
|
end; |
2459 |
|
|
2425 |
– |
function TryStrToNumeric(S: Ansistring; out Value: int64; out scale: integer): boolean; |
2426 |
– |
var i: integer; |
2427 |
– |
ds: integer; |
2428 |
– |
begin |
2429 |
– |
Result := false; |
2430 |
– |
ds := 0; |
2431 |
– |
S := Trim(S); |
2432 |
– |
{$IF declared(DefaultFormatSettings)} |
2433 |
– |
with DefaultFormatSettings do |
2434 |
– |
{$ELSE} |
2435 |
– |
{$IF declared(FormatSettings)} |
2436 |
– |
with FormatSettings do |
2437 |
– |
{$IFEND} |
2438 |
– |
{$IFEND} |
2439 |
– |
begin |
2440 |
– |
{ThousandSeparator not allowed as by Delphi specs} |
2441 |
– |
if (ThousandSeparator <> DecimalSeparator) and |
2442 |
– |
(Pos(ThousandSeparator, S) <> 0) then |
2443 |
– |
Exit; |
2444 |
– |
|
2445 |
– |
for i := length(S) downto 1 do |
2446 |
– |
begin |
2447 |
– |
if S[i] = AnsiChar(DecimalSeparator) then |
2448 |
– |
begin |
2449 |
– |
if ds <> 0 then Exit; {only one allowed} |
2450 |
– |
ds := i-1; |
2451 |
– |
system.Delete(S,i,1); |
2452 |
– |
end |
2453 |
– |
else |
2454 |
– |
if (i > 1) and (S[i] in ['+','-']) then |
2455 |
– |
Exit |
2456 |
– |
else |
2457 |
– |
if not (S[i] in ['0'..'9']) then |
2458 |
– |
Exit; {bad character} |
2459 |
– |
|
2460 |
– |
end; |
2461 |
– |
if ds = 0 then |
2462 |
– |
scale := 0 |
2463 |
– |
else |
2464 |
– |
scale := ds - Length(S); |
2465 |
– |
Result := TryStrToInt64(S,Value); |
2466 |
– |
end; |
2467 |
– |
end; |
2468 |
– |
|
2460 |
|
var b: IBlob; |
2461 |
|
dt: TDateTime; |
2462 |
|
timezone: AnsiString; |
2472 |
– |
{$ifdef FPC_HAS_TYPE_EXTENDED} |
2473 |
– |
FloatValue: Extended; |
2474 |
– |
{$else} |
2475 |
– |
FloatValue: Double; |
2476 |
– |
{$endif} |
2463 |
|
Int64Value: Int64; |
2464 |
|
BCDValue: TBCD; |
2465 |
|
aScale: integer; |
2498 |
|
SQL_LONG, |
2499 |
|
SQL_INT64: |
2500 |
|
if TryStrToNumeric(Value,Int64Value,aScale) then |
2501 |
< |
begin |
2516 |
< |
if aScale = 0 then |
2517 |
< |
SetAsInt64(Int64Value) |
2518 |
< |
else |
2519 |
< |
SetAsNumeric(Int64Value,aScale); |
2520 |
< |
end |
2521 |
< |
else |
2522 |
< |
if TryStrToFloat(Value,FloatValue) then |
2523 |
< |
SetAsDouble(FloatValue) |
2501 |
> |
SetAsNumeric(Int64Value,aScale) |
2502 |
|
else |
2503 |
|
DoSetString; |
2504 |
|
|
2514 |
|
SQL_D_FLOAT, |
2515 |
|
SQL_DOUBLE, |
2516 |
|
SQL_FLOAT: |
2517 |
< |
if TryStrToFloat(Value,FloatValue) then |
2518 |
< |
SetAsDouble(FloatValue) |
2517 |
> |
if TryStrToNumeric(Value,Int64Value,aScale) then |
2518 |
> |
SetAsDouble(NumericToDouble(Int64Value,aScale)) |
2519 |
|
else |
2520 |
|
DoSetString; |
2521 |
|
|