ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/ibxscript.pas
(Generate patch)

Comparing ibx/trunk/runtime/ibxscript.pas (file contents):
Revision 79 by tony, Mon Mar 27 15:21:02 2017 UTC vs.
Revision 80 by tony, Mon Jan 1 11:31:07 2018 UTC

# Line 253 | Line 253 | type
253    TLogEvent = procedure(Sender: TObject; Msg: string) of Object;
254    TOnSelectSQL = procedure (Sender: TObject; SQLText: string) of object;
255    TOnSetStatement = procedure(Sender: TObject; command, aValue, stmt: string; var Done: boolean) of object;
256 +  TOnCreateDatabase = procedure (Sender: TObject; var DatabaseFileName: string) of object;
257  
258    { TCustomIBXScript }
259  
# Line 274 | Line 275 | type
275      FDatabase: TIBDatabase;
276      FDataOutputFormatter: TIBCustomDataOutput;
277      FIgnoreGrants: boolean;
278 +    FOnCreateDatabase: TOnCreateDatabase;
279      FOnErrorLog: TLogEvent;
280      FOnSelectSQL: TOnSelectSQL;
281      FOnSetStatement: TOnSetStatement;
# Line 325 | Line 327 | type
327      property OnProgressEvent: TOnProgressEvent read GetOnProgressEvent write SetOnProgressEvent; {Progress Bar Support}
328      property OnSelectSQL: TOnSelectSQL read FOnSelectSQL write FOnSelectSQL; {Handle Select SQL Statements}
329      property OnSetStatement: TOnSetStatement read FOnSetStatement write FOnSetStatement;
330 +    property OnCreateDatabase: TOnCreateDatabase read FOnCreateDatabase write FOnCreateDatabase;
331    end;
332  
333    {
# Line 723 | Line 726 | begin
726  
727    except on E:Exception do
728        begin
729 <        Add2Log(Format(sStatementError,[FSymbolStream.GetErrorPrefix,
730 <                           E.Message,stmt]),true);
731 <        if StopOnFirstError then Exit;
729 >        if FInternalTransaction.InTransaction then
730 >          FInternalTransaction.Rollback;
731 >        if assigned(OnErrorLog) then
732 >        begin
733 >          Add2Log(Format(sStatementError,[FSymbolStream.GetErrorPrefix,
734 >                             E.Message,stmt]),true);
735 >                             if StopOnFirstError then Exit;
736 >        end
737 >        else
738 >          raise;
739        end
740    end;
741    Result := true;
# Line 838 | Line 848 | var  RegexObj: TRegExpr;
848       charsetid: integer;
849       param: string;
850       Terminator: char;
851 +     FileName: string;
852   begin
853    Result := false;
854    ucStmt := AnsiUpperCase(stmt);
# Line 845 | Line 856 | begin
856    RegexObj := TRegExpr.Create;
857    try
858      {process create database}
859 <    RegexObj.Expression := '^ *CREATE +(DATABASE|SCHEMA) +.*(\' + Terminator + '|)';
859 >    RegexObj.Expression := '^ *CREATE +(DATABASE|SCHEMA) +''(.*)''(.*)(\' + Terminator + '|)';
860      if RegexObj.Exec(ucStmt) then
861      begin
862 +      FileName := system.copy(stmt,RegexObj.MatchPos[2], RegexObj.MatchLen[2]);
863 +      if assigned(FOnCreateDatabase) then
864 +        OnCreateDatabase(self,FileName);
865 +      stmt := 'CREATE DATABASE ''' + FileName + '''' + system.copy(stmt,RegexObj.MatchPos[3], RegexObj.MatchLen[3]);
866 +      ucStmt := AnsiUpperCase(stmt);
867        UpdateUserPassword;
868        FDatabase.Connected := false;
869        FDatabase.CreateDatabase(stmt);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines