Page 1 of 1

Demo(s) for Services?

Posted: Wed 06 Feb 2013 17:51
by kstantonnw
Greetings.

I'm looking/searching for demos for the services like backup/restore/statistical/etc. and am not finding any. Very frustrating.

Can anyone point me in the right direction?

Thanks in advance.

Kevin

Re: Demo(s) for Services?

Posted: Thu 07 Feb 2013 10:32
by AndreyZ
Hello,

For the time being, we do not have demo projects that demonstrate using of services components. We will try to add such demo projects in one of the next versions of IBDAC.
Here are code examples of using the TIBCBackupService, TIBCRestoreService, and TIBCStatisticalService components:

Code: Select all

// backing up a database
IBCBackupService.Server := 'server';
IBCBackupService.Database := 'database';
IBCBackupService.Username := 'sysdba';
IBCBackupService.Password := 'masterkey';
IBCBackupService.ClientLibrary := 'fbclient.dll';
IBCBackupService.LoginPrompt := False;
IBCBackupService.BackupFile.Text := 'C:\backup.bak';
IBCBackupService.Attach;
try
  IBCBackupService.ServiceStart;
  while IBCBackupService.IsServiceRunning do
    sleep(500);
finally
  IBCBackupService.Detach;
end;

Code: Select all

// restoring a database from a backup file
IBCRestoreService.Server := 'server';
IBCRestoreService.Database.Text := 'database';
IBCRestoreService.Username := 'sysdba';
IBCRestoreService.Password := 'masterkey';
IBCRestoreService.ClientLibrary := 'fbclient.dll';
IBCRestoreService.LoginPrompt := False;
IBCRestoreService.BackupFile.Text := 'C:\backup.bak';
IBCRestoreService.Attach;
try
  IBCRestoreService.ServiceStart;
  while IBCRestoreService.IsServiceRunning do
    sleep(500);
finally
  IBCRestoreService.Detach;
end;

Code: Select all

// getting database statistics
IBCStatisticalService.Server := 'server';
IBCStatisticalService.Database := 'database';
IBCStatisticalService.Username := 'sysdba';
IBCStatisticalService.Password := 'masterkey';
IBCStatisticalService.ClientLibrary := 'fbclient.dll';
IBCStatisticalService.LoginPrompt := False;
IBCStatisticalService.Attach;
try
  IBCStatisticalService.ServiceStart;
  while not IBCStatisticalService.Eof do
    Memo.Lines.Add(IBCStatisticalService.GetNextLine); // Memo is a TMemo component
finally
  IBCStatisticalService.Detach;
end;
You can find the description of the TIBCBackupService, TIBCRestoreService, and TIBCStatisticalService components in the IBDAC documentation.

Re: Demo(s) for Services?

Posted: Tue 12 Feb 2013 16:34
by kstantonnw
Perfect - thank you! I hope to try these out today.
Kevin

Re: Demo(s) for Services?

Posted: Tue 12 Feb 2013 18:03
by kstantonnw
Another question: How do I get a complete log of the backup service?

After setting the component to Verbose = True, I tried this:

procedure TfrmDBStats.btnBackupClick(Sender: TObject);
begin
IBCBackupService1.Server := 'MyServer';
IBCBackupService1.Database := 'c:\MyDatabase.fdb';
IBCBackupService1.Username := 'sysdba';
IBCBackupService1.Password := 'masterkey';
IBCBackupService1.ClientLibrary := 'gds32.dll';
IBCBackupService1.LoginPrompt := False;
IBCBackupService1.BackupFile.Text := 'c:\MyDatabase_Backup.fbk';
IBCBackupService1.Attach;
try
IBCBackupService1.ServiceStart;
while IBCBackupService1.IsServiceRunning do
begin
Memo1.Lines.Add(IBCBackupService1.GetNextLine);
Application.ProcessMessages;
// sleep(500);
end;
finally
Memo1.Lines.Add(IBCBackupService1.GetNextLine);
IBCBackupService1.Detach;
end;


ShowMessage('backup complete');

end;



but only get down to this in the log:
...
gbak: writing constraint PK_AAFP_FIX_LOG
gbak: writing constraint INTEG_1703
gbak: writing constraint PK_PROSPECTS
gbak: writing constraint INTEG_1704
gbak: writing constraint INTEG_1705
gbak: writing constraint PK_PROSPECT_LOCS
gbak: writing constraint FK_PROSPECT_LOCS_1
gbak: writing constraint INTEG_1706
gbak: writing constraint INTEG_1707


I need to get the last set of lines including:
"gbak: closing file, committing, and finishing. 13867520 bytes written"


Any ideas as to how?

Thanks,
Kevin

Re: Demo(s) for Services?

Posted: Wed 13 Feb 2013 09:25
by AndreyZ
You should use the following code:

Code: Select all

IBCBackupService.Server := 'server';
IBCBackupService.Database := 'database';
IBCBackupService.Username := 'sysdba';
IBCBackupService.Password := 'masterkey';
IBCBackupService.ClientLibrary := 'fbclient.dll';
IBCBackupService.LoginPrompt := False;
IBCBackupService.BackupFile.Text := 'C:\backup.bak';
IBCBackupService.Verbose := True;
IBCBackupService.Attach;
try
  IBCBackupService.ServiceStart;
  while not IBCBackupService.Eof do begin
    Memo1.Lines.Add(IBCBackupService.GetNextLine);
    Application.ProcessMessages;
  end;
finally
  IBCBackupService.Detach;
end;

Re: Demo(s) for Services?

Posted: Wed 13 Feb 2013 23:28
by kstantonnw
Perfect! Exactly what I needed. I would've never guessed. (need demos! :) )

Re: Demo(s) for Services?

Posted: Thu 14 Feb 2013 10:27
by AndreyZ
I am glad I could help.

Re: Demo(s) for Services?

Posted: Mon 25 Feb 2013 23:11
by bzwirs
Hi,

Further to the examples you have provided, can you please give an axample of using the validation service component.

Thanks in advance

Bill Zwirs

Re: Demo(s) for Services?

Posted: Tue 26 Feb 2013 11:28
by AndreyZ
You can use the following code:

Code: Select all

IBCValidationService.Server := 'server';
IBCValidationService.Database := 'database';
IBCValidationService.Username := 'sysdba';
IBCValidationService.Password := 'masterkey';
IBCValidationService.ClientLibrary := 'fbclient.dll';
IBCValidationService.LoginPrompt := False;
IBCValidationService.Options := [voValidateDB];
IBCValidationService.Attach;
try
  IBCValidationService.ServiceStart;
  while not IBCValidationService.Eof do
    Memo1.Lines.Add(IBCValidationService.GetNextLine);
finally
  IBCValidationService.Detach;
end;
Please note, that some commands do not give any output.