Browse Source

fcl-db: dbtestframework:
* Cosmetic: Oracle, MySQL drop table command convenience call

git-svn-id: trunk@26937 -

reiniero 11 years ago
parent
commit
cb9c15a256
1 changed files with 17 additions and 1 deletions
  1. 17 1
      packages/fcl-db/tests/sqldbtoolsunit.pas

+ 17 - 1
packages/fcl-db/tests/sqldbtoolsunit.pas

@@ -535,7 +535,7 @@ end;
 procedure TSQLDBConnector.TryDropIfExist(ATableName: String);
 begin
   // This makes life soo much easier, since it avoids the exception if the table already
-  // exists. And while this exeption is in a try..except statement, the debugger
+  // exists. And while this exception is in a try..except statement, the debugger
   // always shows the exception, which is pretty annoying.
   try
     case SQLServerType of
@@ -557,6 +557,22 @@ begin
           'drop table ' + ATableName + ' '+
           'end');
         end;
+      ssMySQL:
+        begin
+        FConnection.ExecuteDirect('drop table if exists ' + ATableName);
+        end;
+      ssOracle:
+        begin
+          FConnection.ExecuteDirect(
+          'declare ' +
+          '   c int; ' +
+          'begin ' +
+          '   select count(*) into c from all_tables where table_name = upper(''' + ATableName + '''); ' +
+          '   if c = 1 then ' +
+          '      execute immediate ''drop table ' + ATableName + '''; ' +
+          '   end if; ' +
+          'end; ');
+        end;
       ssSybase:
         begin
         // Checking is needed here to avoid getting "auto rollback" of a subsequent CREATE TABLE statement