|
@@ -77,6 +77,7 @@ type
|
|
|
procedure DropFieldDataset; override;
|
|
|
Function InternalGetNDataset(n : integer) : TDataset; override;
|
|
|
Function InternalGetFieldDataset : TDataSet; override;
|
|
|
+ procedure TryDropIfExist(ATableName : String);
|
|
|
public
|
|
|
destructor Destroy; override;
|
|
|
constructor Create; override;
|
|
@@ -171,6 +172,7 @@ var CountID : Integer;
|
|
|
begin
|
|
|
try
|
|
|
Ftransaction.StartTransaction;
|
|
|
+ TryDropIfExist('FPDEV');
|
|
|
Fconnection.ExecuteDirect('create table FPDEV ( ' +
|
|
|
' ID INT NOT NULL, ' +
|
|
|
' NAME VARCHAR(50), ' +
|
|
@@ -196,6 +198,7 @@ var CountID : Integer;
|
|
|
begin
|
|
|
try
|
|
|
Ftransaction.StartTransaction;
|
|
|
+ TryDropIfExist('FPDEV_FIELD');
|
|
|
|
|
|
Sql := 'create table FPDEV_FIELD (ID INT NOT NULL,';
|
|
|
for FType := low(TFieldType)to high(TFieldType) do
|
|
@@ -283,6 +286,24 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+procedure TSQLDBConnector.TryDropIfExist(ATableName: String);
|
|
|
+begin
|
|
|
+ // This makes live 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
|
|
|
+ // always shows the exception. Which is pretty annoying
|
|
|
+ // It only works with Firebird 2, though.
|
|
|
+ try
|
|
|
+ if SQLDbType = INTERBASE then
|
|
|
+ begin
|
|
|
+ FConnection.ExecuteDirect('execute block as begin if (exists (select 1 from rdb$relations where rdb$relation_name=''FPDEV_FIELD'')) '+
|
|
|
+ 'then execute statement ''drop table ' + ATAbleName + ';'';end');
|
|
|
+ FTransaction.CommitRetaining;
|
|
|
+ end;
|
|
|
+ except
|
|
|
+ FTransaction.RollbackRetaining;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
destructor TSQLDBConnector.Destroy;
|
|
|
begin
|
|
|
if assigned(FTransaction) then
|