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 |
|
|
275 |
|
FDatabase: TIBDatabase; |
276 |
|
FDataOutputFormatter: TIBCustomDataOutput; |
277 |
|
FIgnoreGrants: boolean; |
278 |
+ |
FOnCreateDatabase: TOnCreateDatabase; |
279 |
|
FOnErrorLog: TLogEvent; |
280 |
|
FOnSelectSQL: TOnSelectSQL; |
281 |
|
FOnSetStatement: TOnSetStatement; |
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 |
|
{ |
652 |
|
|
653 |
|
procedure TCustomIBXScript.SetDatabase(AValue: TIBDatabase); |
654 |
|
begin |
655 |
< |
if FDatabase = AValue then Exit; |
655 |
> |
if not (csLoading in ComponentState) and (FDatabase = AValue) then Exit; |
656 |
|
FDatabase := AValue; |
657 |
|
FISQL.Database := AValue; |
658 |
|
FIBXMLProcessor.Database := AValue; |
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; |
848 |
|
charsetid: integer; |
849 |
|
param: string; |
850 |
|
Terminator: char; |
851 |
+ |
FileName: string; |
852 |
|
begin |
853 |
|
Result := false; |
854 |
|
ucStmt := AnsiUpperCase(stmt); |
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); |