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 |
|
{ |
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); |
964 |
|
else |
965 |
|
if command = 'NAMES' then |
966 |
|
begin |
967 |
< |
if FirebirdAPI.CharSetName2CharSetID(param,charsetid) then |
967 |
> |
if Database.Attachment.CharSetName2CharSetID(param,charsetid) then |
968 |
|
begin |
969 |
|
Database.Params.Values['lc_ctype'] := param; |
970 |
|
if Database.Connected then |
1279 |
|
begin |
1280 |
|
Database.Connected := true; |
1281 |
|
Transaction.Active := true; |
1282 |
< |
FirebirdAPI.CharSetName2CharSetID(CharSet,aCharSetID); |
1282 |
> |
Database.Attachment.CharSetName2CharSetID(CharSet,aCharSetID); |
1283 |
|
SetLength(Index,dim); |
1284 |
|
ArrayIntf := Database.Attachment.CreateArray( |
1285 |
|
Transaction.TransactionIntf, |
1722 |
|
end; |
1723 |
|
end; |
1724 |
|
|
1725 |
< |
class function TIBXMLProcessor.FormatArray(ar: IArray): string; |
1725 |
> |
class function TIBXMLProcessor.FormatArray(Database: TIBDatabase; ar: IArray |
1726 |
> |
): string; |
1727 |
|
var index: array of integer; |
1728 |
|
TextOut: TStrings; |
1729 |
|
|
1768 |
|
s += Format(' scale = "%d"',[ ar.GetScale]); |
1769 |
|
SQL_TEXT, |
1770 |
|
SQL_VARYING: |
1771 |
< |
s += Format(' charset = "%s"',[FirebirdAPI.GetCharsetName(ar.GetCharSetID)]); |
1771 |
> |
s += Format(' charset = "%s"',[Database.Attachment.GetCharsetName(ar.GetCharSetID)]); |
1772 |
|
end; |
1773 |
|
bounds := ar.GetBounds; |
1774 |
|
boundsList := ''; |