浏览代码

* Added FmtBCD support to Firebird

git-svn-id: trunk@17830 -
joost 14 年之前
父节点
当前提交
23363f3158
共有 1 个文件被更改,包括 24 次插入1 次删除
  1. 24 1
      packages/fcl-db/src/sqldb/interbase/ibconnection.pp

+ 24 - 1
packages/fcl-db/src/sqldb/interbase/ibconnection.pp

@@ -121,7 +121,7 @@ type
 implementation
 
 uses
-  strutils;
+  strutils, FmtBCD;
 
 type
   TTm = packed record
@@ -842,6 +842,8 @@ begin
           begin
             if VSQLVar^.sqlscale = 0 then
               li := AParams[ParNr].AsLargeInt
+            else if AParams[ParNr].DataType = ftFMTBcd then
+              li := Round(AParams[ParNr].AsFMTBCD * IntPower(10, -VSQLVar^.sqlscale))
             else
               li := Round(AParams[ParNr].AsCurrency * IntPower(10, -VSQLVar^.sqlscale));
             Move(li, VSQLVar^.SQLData^, VSQLVar^.SQLLen);
@@ -863,6 +865,7 @@ var
   VarcharLen : word;
   CurrBuff     : pchar;
   c            : currency;
+  AFmtBcd      : tBCD;
   smalli       : smallint;
   longi        : longint;
   largei       : largeint;
@@ -920,6 +923,26 @@ begin
             end; {case}
             Move(c, buffer^ , sizeof(c));
           end;
+        ftFMTBcd :
+          begin
+            case SQLDA^.SQLVar[x].SQLLen of
+              2 : begin
+                  Move(CurrBuff^, smalli, 2);
+                  AFmtBCD:= smalli*intpower(10,SQLDA^.SQLVar[x].SQLScale);
+                  end;
+              4 : begin
+                  Move(CurrBuff^, longi, 4);
+                  AFmtBcd := longi*intpower(10,SQLDA^.SQLVar[x].SQLScale);
+                  end;
+              8 : begin
+                  Move(CurrBuff^, largei, 8);
+                  AFmtBcd := largei*intpower(10,SQLDA^.SQLVar[x].SQLScale);
+                  end;
+              else
+                Result := False; // Just to be sure, in principle this will never happen
+            end; {case}
+            Move(AFmtBcd, buffer^ , sizeof(AFmtBcd));
+          end;
         ftInteger :
           begin
             FillByte(buffer^,sizeof(Longint),0);