Browse Source

* Patch from Lacak2 for Mantis #18699 Improve numeric formatting for
interbase.

git-svn-id: trunk@20382 -

marco 13 years ago
parent
commit
48d780b920
1 changed files with 16 additions and 5 deletions
  1. 16 5
      packages/fcl-db/src/sqldb/interbase/ibconnection.pp

+ 16 - 5
packages/fcl-db/src/sqldb/interbase/ibconnection.pp

@@ -165,7 +165,6 @@ constructor TIBConnection.Create(AOwner : TComponent);
 begin
 begin
   inherited;
   inherited;
   FConnOptions := FConnOptions + [sqSupportParams] + [sqEscapeRepeat];
   FConnOptions := FConnOptions + [sqSupportParams] + [sqEscapeRepeat];
-  FieldNameQuoteChars:=DoubleQuotes;
   FBLobSegmentSize := 65535; //Shows we're using the maximum segment size
   FBLobSegmentSize := 65535; //Shows we're using the maximum segment size
   FDialect := -1;
   FDialect := -1;
   FDBDialect := -1;
   FDBDialect := -1;
@@ -652,9 +651,14 @@ begin
 end;
 end;
 
 
 procedure TIBConnection.DoConnect;
 procedure TIBConnection.DoConnect;
+const NoQuotes: TQuoteChars = (' ',' ');
 begin
 begin
   inherited DoConnect;
   inherited DoConnect;
-  FDbDialect := GetDBDialect;
+  FDBDialect := GetDBDialect;
+  if Dialect < 3 then
+    FieldNameQuoteChars := NoQuotes
+  else
+    FieldNameQuoteChars := DoubleQuotes;
 end;
 end;
 
 
 procedure TIBConnection.FreeFldBuffers(cursor : TSQLCursor);
 procedure TIBConnection.FreeFldBuffers(cursor : TSQLCursor);
@@ -706,10 +710,11 @@ begin
 
 
       FD := TFieldDef.Create(FieldDefs, FieldDefs.MakeNameUnique(SQLDA^.SQLVar[x].AliasName), TransType,
       FD := TFieldDef.Create(FieldDefs, FieldDefs.MakeNameUnique(SQLDA^.SQLVar[x].AliasName), TransType,
          TransLen, (SQLDA^.SQLVar[x].sqltype and 1)=0, (x + 1));
          TransLen, (SQLDA^.SQLVar[x].sqltype and 1)=0, (x + 1));
-      if TransType = ftBCD then
+      if TransType in [ftBCD, ftFmtBCD] then
         case (SQLDA^.SQLVar[x].sqltype and not 1) of
         case (SQLDA^.SQLVar[x].sqltype and not 1) of
           SQL_SHORT : FD.precision := 4;
           SQL_SHORT : FD.precision := 4;
           SQL_LONG  : FD.precision := 9;
           SQL_LONG  : FD.precision := 9;
+          SQL_DOUBLE,
           SQL_INT64 : FD.precision := 18;
           SQL_INT64 : FD.precision := 18;
           else FD.precision := SQLDA^.SQLVar[x].SQLLen;
           else FD.precision := SQLDA^.SQLVar[x].SQLLen;
         end;
         end;
@@ -952,7 +957,10 @@ begin
             case SQLDA^.SQLVar[x].SQLLen of
             case SQLDA^.SQLVar[x].SQLLen of
               2 : c := PSmallint(CurrBuff)^ / IntPower10(-SQLDA^.SQLVar[x].SQLScale);
               2 : c := PSmallint(CurrBuff)^ / IntPower10(-SQLDA^.SQLVar[x].SQLScale);
               4 : c := PLongint(CurrBuff)^  / IntPower10(-SQLDA^.SQLVar[x].SQLScale);
               4 : c := PLongint(CurrBuff)^  / IntPower10(-SQLDA^.SQLVar[x].SQLScale);
-              8 : c := PLargeint(CurrBuff)^ / IntPower10(-SQLDA^.SQLVar[x].SQLScale);
+              8 : if Dialect < 3 then
+                    c := PDouble(CurrBuff)^
+                  else
+                    c := PLargeint(CurrBuff)^ / IntPower10(-SQLDA^.SQLVar[x].SQLScale);
               else
               else
                 Result := False; // Just to be sure, in principle this will never happen
                 Result := False; // Just to be sure, in principle this will never happen
             end; {case}
             end; {case}
@@ -963,7 +971,10 @@ begin
             case SQLDA^.SQLVar[x].SQLLen of
             case SQLDA^.SQLVar[x].SQLLen of
               2 : AFmtBcd := BcdDivPower10(PSmallint(CurrBuff)^, -SQLDA^.SQLVar[x].SQLScale);
               2 : AFmtBcd := BcdDivPower10(PSmallint(CurrBuff)^, -SQLDA^.SQLVar[x].SQLScale);
               4 : AFmtBcd := BcdDivPower10(PLongint(CurrBuff)^,  -SQLDA^.SQLVar[x].SQLScale);
               4 : AFmtBcd := BcdDivPower10(PLongint(CurrBuff)^,  -SQLDA^.SQLVar[x].SQLScale);
-              8 : AFmtBcd := BcdDivPower10(PLargeint(CurrBuff)^, -SQLDA^.SQLVar[x].SQLScale);
+              8 : if Dialect < 3 then
+                    AFmtBcd := PDouble(CurrBuff)^
+                  else
+                    AFmtBcd := BcdDivPower10(PLargeint(CurrBuff)^, -SQLDA^.SQLVar[x].SQLScale);
               else
               else
                 Result := False; // Just to be sure, in principle this will never happen
                 Result := False; // Just to be sure, in principle this will never happen
             end; {case}
             end; {case}