Browse Source

fcl-db: oracle:
- map NUMBER columns with precision < 5 to ftSmallint
- fix some tests for Oracle

git-svn-id: trunk@27997 -

lacak 11 years ago
parent
commit
0106f860eb

+ 9 - 2
packages/fcl-db/src/sqldb/oracle/oracleconnection.pp

@@ -726,7 +726,7 @@ end;
 
 procedure TOracleConnection.Execute(cursor: TSQLCursor; ATransaction: TSQLTransaction; AParams: TParams);
 begin
-  if Assigned(APArams) and (AParams.count > 0) then SetParameters(cursor, AParams);
+  if Assigned(AParams) and (AParams.Count > 0) then SetParameters(cursor, AParams);
   if cursor.FStatementType = stSelect then
     begin
     if OCIStmtExecute(TOracleTrans(ATransaction.Handle).FOciSvcCtx,(cursor as TOracleCursor).FOciStmt,FOciError,0,0,nil,nil,OCI_DEFAULT) = OCI_ERROR then
@@ -736,7 +736,7 @@ begin
     begin
     if OCIStmtExecute(TOracleTrans(ATransaction.Handle).FOciSvcCtx,(cursor as TOracleCursor).FOciStmt,FOciError,1,0,nil,nil,OCI_DEFAULT) = OCI_ERROR then
       HandleError;
-    if Assigned(APArams) and (AParams.count > 0) then GetParameters(cursor, AParams);
+    if Assigned(AParams) and (AParams.Count > 0) then GetParameters(cursor, AParams);
     end;
 end;
 
@@ -811,6 +811,12 @@ begin
                                     OFieldType := SQLT_VNU;
                                     OFieldSize:= 22;
                                     end
+                                  else if Oprecision < 5 then
+                                    begin
+                                    FieldType := ftSmallint;
+                                    OFieldType := SQLT_INT;
+                                    OFieldSize := sizeof(smallint);
+                                    end
                                   else
                                     begin
                                     FieldType := ftInteger;
@@ -948,6 +954,7 @@ begin
                            pBCD(buffer)^:= Nvu2FmtBCE(fieldbuffers[FieldDef.FieldNo-1].buffer);
                            end;
       ftFloat           : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,sizeof(double));
+      ftSmallInt        : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,sizeof(smallint));
       ftInteger         : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,sizeof(integer));
       ftDate  : begin
                 b := fieldbuffers[FieldDef.FieldNo-1].buffer;

+ 7 - 2
packages/fcl-db/tests/testfieldtypes.pas

@@ -258,6 +258,11 @@ begin
       datatype  := 'TINYINT UNSIGNED';
       fieldtype := ftWord;
       end;
+    ssOracle:
+      begin
+      datatype  := 'NUMBER(3)';
+      fieldtype := ftSmallint;
+      end;
     ssSQLite:
       begin
       datatype  := 'TINYINT';
@@ -2301,7 +2306,7 @@ begin
   with TSQLDBConnector(DBConnector).Query do
     begin
     SQL.Clear;
-    if SQLServerType in [ssFirebird, ssInterbase] then
+    if SQLServerType in [ssFirebird, ssInterbase, ssOracle] then
       // Global temporary table: introduced in Firebird 2.1
       // has persistent metadata; data is per transaction (default) or per connection
       SQL.Add('CREATE GLOBAL TEMPORARY TABLE FPDEV_TEMP (id int)')
@@ -2320,7 +2325,7 @@ begin
       Close;
     finally
       // For Firebird/Interbase, we need to explicitly delete the table as well (it's active within the transaction)
-      if SQLServerType in [ssFirebird, ssInterbase] then
+      if SQLServerType in [ssFirebird, ssInterbase, ssOracle] then
         begin
         SQL.Text := 'DROP TABLE FPDEV_TEMP';
         ExecSQL;