mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-04 06:10:16 +02:00
fcl-db: tests: use SQLServerType instead of SQLConnType.
To allow correctly testing TODBCConnection. (we need know remote DB server to setup some tests) git-svn-id: trunk@23074 -
This commit is contained in:
parent
18d6e113b6
commit
595e413950
@ -476,36 +476,38 @@ begin
|
||||
// exists. And while this exeption is in a try..except statement, the debugger
|
||||
// always shows the exception, which is pretty annoying.
|
||||
try
|
||||
if SQLConnType = INTERBASE then
|
||||
begin
|
||||
// This only works with Firebird 2+
|
||||
FConnection.ExecuteDirect('execute block as begin if (exists (select 1 from rdb$relations where rdb$relation_name=''' + ATableName + ''')) '+
|
||||
'then execute statement ''drop table ' + ATAbleName + ';'';end');
|
||||
FTransaction.CommitRetaining;
|
||||
end;
|
||||
if SQLConnType = mssql then
|
||||
begin
|
||||
// Checking is needed here to avoid getting "auto rollback" of a subsequent CREATE TABLE statement
|
||||
// which leads to the rollback not referring to the right transaction=>SQL error
|
||||
// Use SQL92 ISO standard INFORMATION_SCHEMA:
|
||||
FConnection.ExecuteDirect(
|
||||
'if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_TYPE=''BASE TABLE'' AND TABLE_NAME=''' + ATableName + ''') '+
|
||||
'begin '+
|
||||
'drop table ' + ATAbleName + ' '+
|
||||
'end');
|
||||
FTransaction.CommitRetaining;
|
||||
end;
|
||||
if SQLConnType = sybase then
|
||||
begin
|
||||
// Checking is needed here to avoid getting "auto rollback" of a subsequent CREATE TABLE statement
|
||||
// which leads to the rollback not referring to the right transaction=>SQL error
|
||||
// Can't use SQL standard information_schema; instead query sysobjects for User tables
|
||||
FConnection.ExecuteDirect(
|
||||
'if exists (select * from sysobjects where type = ''U'' and name=''' + ATableName + ''') '+
|
||||
'begin '+
|
||||
'drop table ' + ATAbleName + ' '+
|
||||
'end');
|
||||
end;
|
||||
case SQLServerType of
|
||||
ssFirebird:
|
||||
begin
|
||||
// This only works with Firebird 2+
|
||||
FConnection.ExecuteDirect('execute block as begin if (exists (select 1 from rdb$relations where rdb$relation_name=''' + ATableName + ''')) '+
|
||||
'then execute statement ''drop table ' + ATableName + ';'';end');
|
||||
FTransaction.CommitRetaining;
|
||||
end;
|
||||
ssMSSQL:
|
||||
begin
|
||||
// Checking is needed here to avoid getting "auto rollback" of a subsequent CREATE TABLE statement
|
||||
// which leads to the rollback not referring to the right transaction=>SQL error
|
||||
// Use SQL92 ISO standard INFORMATION_SCHEMA:
|
||||
FConnection.ExecuteDirect(
|
||||
'if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_TYPE=''BASE TABLE'' AND TABLE_NAME=''' + ATableName + ''') '+
|
||||
'begin '+
|
||||
'drop table ' + ATableName + ' '+
|
||||
'end');
|
||||
FTransaction.CommitRetaining;
|
||||
end;
|
||||
ssSybase:
|
||||
begin
|
||||
// Checking is needed here to avoid getting "auto rollback" of a subsequent CREATE TABLE statement
|
||||
// which leads to the rollback not referring to the right transaction=>SQL error
|
||||
// Can't use SQL standard information_schema; instead query sysobjects for User tables
|
||||
FConnection.ExecuteDirect(
|
||||
'if exists (select * from sysobjects where type = ''U'' and name=''' + ATableName + ''') '+
|
||||
'begin '+
|
||||
'drop table ' + ATableName + ' '+
|
||||
'end');
|
||||
end;
|
||||
end;
|
||||
except
|
||||
FTransaction.RollbackRetaining;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user