Browse Source

* update decimal support with newer ftfmtbcd support. Mantis #19664 patch by Lacak2.

git-svn-id: trunk@18991 -
marco 14 years ago
parent
commit
5c20a50536
1 changed files with 21 additions and 14 deletions
  1. 21 14
      packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

+ 21 - 14
packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

@@ -179,7 +179,8 @@ uses
   dbconst,
   ctypes,
   strutils,
-  dateutils;
+  dateutils,
+  FmtBCD;
 
 const
   Mysql_Option_Names : array[mysql_option] of string = ('MYSQL_OPT_CONNECT_TIMEOUT','MYSQL_OPT_COMPRESS',
@@ -563,19 +564,19 @@ begin
 {$ifdef mysql50_up}
     FIELD_TYPE_NEWDECIMAL,
 {$endif}
-    FIELD_TYPE_DECIMAL: begin
-			  ADecimals:=AField^.decimals;
-                          if ADecimals < 5 then
-                            begin
-                            NewType := ftBCD;
-                            NewSize := ADecimals;
-                            end
-                          else
-                            begin
-                            NewType := ftFloat;
-                            NewSize := 0;
-                            end;
-                       end;
+    FIELD_TYPE_DECIMAL: 
+      begin
+        if (ADecimals < 5) and (ASize-2-ADecimals < 15) then //ASize is display size i.e. with sign and decimal point
+          NewType := ftBCD
+        else 
+          begin
+            if (ADecimals = 0) and (ASize < 20) then
+              NewType := ftLargeInt
+            else
+              NewType := ftFmtBCD;
+          end;
+        NewSize := ADecimals;
+      end;
     FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE:
       begin
       NewType := ftFloat;
@@ -845,6 +846,7 @@ var
   VF: Double;
   VC: Currency;
   VD: TDateTime;
+  VB: TBCD;
   Src : String;
 
 begin
@@ -887,6 +889,11 @@ begin
         VC := InternalStrToCurrency(Src);
         Move(VC, Dest^, SizeOf(Currency));
         end
+      else if AFieldType = ftFmtBCD then
+        begin
+        VB:=StrToBCD(Src, FSQLFormatSettings);
+        Move(VB, Dest^, SizeOf(TBCD));
+        end
       else
         begin
         if Src <> '' then