[firebase-br] IBRestoreService: como descobrir e tratar erros
Valdir Marcos
valdir.marcos em ig.com.br
Qui Nov 17 21:42:11 -03 2005
Delphi 7 + IBX + FB 1.5.2.4787
1. Pessoal, como descobrir se houve algum erro durante o evento de restore
abaixo
2. Um simples Try/Except resvolveria para tratar os erros no evento abaixo?
Um abraço,
Valdir Marcos
http://bdn.borland.com/article/borcon/files/6100/paper/6100.html#IBBackupService
procedure TMainForm.BackupBtnClick(Sender: TObject);
begin
with IBRestoreService
begin
BuMemo.Lines.Clear;
try
ShowWait;
Active := True;
ServiceStart;
while not EOF do begin
BuMemo.Lines.Add(GetNextLine); Application.ProcessMessages;
end; end;
finally
Active := False;
ShowNormal;
end; //try
end; //with
end;
IBRestoreServiceUsing IBRestoreService you can restore a backup made with
IBBackupService or gbak. The following code from the sample application sets
the properties required to restore the database.procedure
TMainDm.SetIbRestoreProperties;
begin
with IBRestore do
begin
SetCommonProperties(IBRestore);
Verbose := True;
DatabaseName.Clear;
DatabaseName.Add(IbDbPath + IbDbName);
BackupFile.Clear;
BackupFile.Add(IbDbPath + IbDbBackup);
end; //with
end;
Note that unlike IBBackupService the DatabaseName property of
IBRestoreService is of type TStrings so you can create a multi-file database
as part of the restore operation. You can also set the PageSize and
PageBuffers properties if you want the page size or cache size of the
restored database to differ from the original. In addition, the Options
property provides all of the options provided by gbak as shown in the
following table.DeactivateIndexes Do not rebuild indexes during the restore.
NoShadow Do not recreate database shadow files. NoValidityCheck Do not
restore data constraints. OneRelationAtATime Restore the metadata and data
for each table together. Replace Overwrite the exiting database. CreateNewDb
Create a new database file. UseAllSpace Does not reserve space on each data
page for record versions. Useful for restoring a read-only database to make
it as small as possible. The following code is the OnClick event for the
Restore Database button.procedure TMainForm.RestoreBtnClick(Sender:
TObject);
begin
with MainDm.IBRestore do
begin
BuMemo.Lines.Clear;
try
ShowWait;
Active := True;
ServiceStart;
while not EOF do
BuMemo.Lines.Add(GetNextLine);
finally
Active := False;
ShowNormal;
end; //try
end; //with
end;
This code is virtually identical to the code used to backup the database.
Once again the Verbose property is set to True and the progress messages are
added to the memo component by the while loop.
Mais detalhes sobre a lista de discussão lista