214 |
|
function AnalyseXML(SymbolStream: TSymbolStream): string; |
215 |
|
procedure NextStatement; |
216 |
|
class function FormatBlob(Field: ISQLData): string; |
217 |
< |
class function FormatArray(ar: IArray): string; |
217 |
> |
class function FormatArray(Database: TIBDatabase; ar: IArray): string; |
218 |
|
property BlobData[index: integer]: TBlobData read GetBlobData; |
219 |
|
property BlobDataCount: integer read GetBlobDataCount; |
220 |
|
property ArrayData[index: integer]: TArrayData read GetArrayData; |
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 |
|
{ |
566 |
|
end; |
567 |
|
|
568 |
|
procedure TCustomIBXScript.DoReconnect; |
569 |
+ |
var LoginPrompt: boolean; |
570 |
|
begin |
571 |
|
with GetTransaction do |
572 |
|
if InTransaction then Commit; |
573 |
+ |
LoginPrompt := Database.LoginPrompt; |
574 |
+ |
Database.LoginPrompt := false; |
575 |
|
Database.Connected := false; |
576 |
|
Database.Connected := true; |
577 |
+ |
Database.LoginPrompt := LoginPrompt; |
578 |
|
GetTransaction.Active := true; |
579 |
|
end; |
580 |
|
|
656 |
|
|
657 |
|
procedure TCustomIBXScript.SetDatabase(AValue: TIBDatabase); |
658 |
|
begin |
659 |
< |
if FDatabase = AValue then Exit; |
659 |
> |
if not (csLoading in ComponentState) and (FDatabase = AValue) then Exit; |
660 |
|
FDatabase := AValue; |
661 |
|
FISQL.Database := AValue; |
662 |
|
FIBXMLProcessor.Database := AValue; |
730 |
|
|
731 |
|
except on E:Exception do |
732 |
|
begin |
733 |
< |
Add2Log(Format(sStatementError,[FSymbolStream.GetErrorPrefix, |
734 |
< |
E.Message,stmt]),true); |
735 |
< |
if StopOnFirstError then Exit; |
733 |
> |
if FInternalTransaction.InTransaction then |
734 |
> |
FInternalTransaction.Rollback; |
735 |
> |
if assigned(OnErrorLog) then |
736 |
> |
begin |
737 |
> |
Add2Log(Format(sStatementError,[FSymbolStream.GetErrorPrefix, |
738 |
> |
E.Message,stmt]),true); |
739 |
> |
if StopOnFirstError then Exit; |
740 |
> |
end |
741 |
> |
else |
742 |
> |
raise; |
743 |
|
end |
744 |
|
end; |
745 |
|
Result := true; |
852 |
|
charsetid: integer; |
853 |
|
param: string; |
854 |
|
Terminator: char; |
855 |
+ |
FileName: string; |
856 |
+ |
DBConnected: boolean; |
857 |
+ |
LoginPrompt: boolean; |
858 |
|
begin |
859 |
|
Result := false; |
860 |
|
ucStmt := AnsiUpperCase(stmt); |
862 |
|
RegexObj := TRegExpr.Create; |
863 |
|
try |
864 |
|
{process create database} |
865 |
< |
RegexObj.Expression := '^ *CREATE +(DATABASE|SCHEMA) +.*(\' + Terminator + '|)'; |
865 |
> |
RegexObj.Expression := '^ *CREATE +(DATABASE|SCHEMA) +''(.*)''(.*)(\' + Terminator + '|)'; |
866 |
|
if RegexObj.Exec(ucStmt) then |
867 |
|
begin |
868 |
+ |
FileName := system.copy(stmt,RegexObj.MatchPos[2], RegexObj.MatchLen[2]); |
869 |
+ |
if assigned(FOnCreateDatabase) then |
870 |
+ |
OnCreateDatabase(self,FileName); |
871 |
+ |
stmt := 'CREATE DATABASE ''' + FileName + '''' + system.copy(stmt,RegexObj.MatchPos[3], RegexObj.MatchLen[3]); |
872 |
+ |
ucStmt := AnsiUpperCase(stmt); |
873 |
|
UpdateUserPassword; |
874 |
|
FDatabase.Connected := false; |
875 |
|
FDatabase.CreateDatabase(stmt); |
970 |
|
else |
971 |
|
if command = 'NAMES' then |
972 |
|
begin |
973 |
< |
if FirebirdAPI.CharSetName2CharSetID(param,charsetid) then |
973 |
> |
if Database.Attachment.CharSetName2CharSetID(param,charsetid) then |
974 |
|
begin |
975 |
+ |
DBConnected := Database.Connected; |
976 |
+ |
LoginPrompt := Database.LoginPrompt; |
977 |
+ |
Database.LoginPrompt := false; |
978 |
+ |
Database.Connected := false; |
979 |
|
Database.Params.Values['lc_ctype'] := param; |
980 |
< |
if Database.Connected then |
981 |
< |
DoReconnect; |
980 |
> |
Database.Connected := DBConnected; |
981 |
> |
Database.LoginPrompt := LoginPrompt; |
982 |
|
end |
983 |
|
else |
984 |
|
raise Exception.CreateFmt(sInvalidCharacterSet, [param,stmt]); |
1289 |
|
begin |
1290 |
|
Database.Connected := true; |
1291 |
|
Transaction.Active := true; |
1292 |
< |
FirebirdAPI.CharSetName2CharSetID(CharSet,aCharSetID); |
1292 |
> |
Database.Attachment.CharSetName2CharSetID(CharSet,aCharSetID); |
1293 |
|
SetLength(Index,dim); |
1294 |
|
ArrayIntf := Database.Attachment.CreateArray( |
1295 |
|
Transaction.TransactionIntf, |
1732 |
|
end; |
1733 |
|
end; |
1734 |
|
|
1735 |
< |
class function TIBXMLProcessor.FormatArray(ar: IArray): string; |
1735 |
> |
class function TIBXMLProcessor.FormatArray(Database: TIBDatabase; ar: IArray |
1736 |
> |
): string; |
1737 |
|
var index: array of integer; |
1738 |
|
TextOut: TStrings; |
1739 |
|
|
1778 |
|
s += Format(' scale = "%d"',[ ar.GetScale]); |
1779 |
|
SQL_TEXT, |
1780 |
|
SQL_VARYING: |
1781 |
< |
s += Format(' charset = "%s"',[FirebirdAPI.GetCharsetName(ar.GetCharSetID)]); |
1781 |
> |
s += Format(' charset = "%s"',[Database.Attachment.GetCharsetName(ar.GetCharSetID)]); |
1782 |
|
end; |
1783 |
|
bounds := ar.GetBounds; |
1784 |
|
boundsList := ''; |