Browse Source

* Added AutoCommit featuresqlscript.pp

git-svn-id: trunk@13369 -
michael 16 years ago
parent
commit
a01d93dda0
1 changed files with 8 additions and 1 deletions
  1. 8 1
      packages/fcl-db/src/base/sqlscript.pp

+ 8 - 1
packages/fcl-db/src/base/sqlscript.pp

@@ -32,6 +32,7 @@ type
 
 
   TCustomSQLScript = class(TComponent)
   TCustomSQLScript = class(TComponent)
   private
   private
+    FAutoCommit: Boolean;
     FLine: Integer;
     FLine: Integer;
     FCol: Integer;
     FCol: Integer;
     FDefines: TStrings;
     FDefines: TStrings;
@@ -75,6 +76,7 @@ type
   protected
   protected
     property Aborted: Boolean read FAborted;
     property Aborted: Boolean read FAborted;
     property Line: Integer read GetLine;
     property Line: Integer read GetLine;
+    Property AutoCommit : Boolean Read FAutoCommit Write FAutoCommit;
     property CommentsInSQL: Boolean read FCommentsInSQL write FCommentsInSQL;
     property CommentsInSQL: Boolean read FCommentsInSQL write FCommentsInSQL;
     property UseSetTerm: Boolean read FUseSetTerm write FUseSetTerm;
     property UseSetTerm: Boolean read FUseSetTerm write FUseSetTerm;
     property UseCommit: Boolean read FUseCommit write FUseCommit;
     property UseCommit: Boolean read FUseCommit write FUseCommit;
@@ -401,7 +403,8 @@ begin
       end
       end
     else If Not FIsSkipping then
     else If Not FIsSkipping then
       begin
       begin
-      if FUseCommit and (Directive = 'COMMIT') then
+      // If AutoCommit, skip any explicit commits.
+      if FUseCommit and (Directive = 'COMMIT') and not FAutoCommit then
         InternalCommit
         InternalCommit
       else if FUseSetTerm and (Directive = 'SET TERM') then
       else if FUseSetTerm and (Directive = 'SET TERM') then
         FTerminator:=S
         FTerminator:=S
@@ -411,7 +414,11 @@ begin
     end
     end
   else
   else
     if (not FIsSkipping) then
     if (not FIsSkipping) then
+      begin
       InternalStatement(FCurrentStatement,FAborted);
       InternalStatement(FCurrentStatement,FAborted);
+      If FAutoCommit and not FAborted then
+        InternalCommit;
+      end;
 end;
 end;
 
 
 procedure TCustomSQLScript.Execute;
 procedure TCustomSQLScript.Execute;