Demo(s) for Services?

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kstantonnw
Posts: 13
Joined: Mon 25 Feb 2008 17:22
Location: Oregon

Demo(s) for Services?

Post by kstantonnw » Wed 06 Feb 2013 17:51

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

AndreyZ

Re: Demo(s) for Services?

Post by AndreyZ » Thu 07 Feb 2013 10:32

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.

kstantonnw
Posts: 13
Joined: Mon 25 Feb 2008 17:22
Location: Oregon

Re: Demo(s) for Services?

Post by kstantonnw » Tue 12 Feb 2013 16:34

Perfect - thank you! I hope to try these out today.
Kevin

kstantonnw
Posts: 13
Joined: Mon 25 Feb 2008 17:22
Location: Oregon

Re: Demo(s) for Services?

Post by kstantonnw » Tue 12 Feb 2013 18:03

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

AndreyZ

Re: Demo(s) for Services?

Post by AndreyZ » Wed 13 Feb 2013 09:25

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;

kstantonnw
Posts: 13
Joined: Mon 25 Feb 2008 17:22
Location: Oregon

Re: Demo(s) for Services?

Post by kstantonnw » Wed 13 Feb 2013 23:28

Perfect! Exactly what I needed. I would've never guessed. (need demos! :) )

AndreyZ

Re: Demo(s) for Services?

Post by AndreyZ » Thu 14 Feb 2013 10:27

I am glad I could help.

bzwirs
Posts: 40
Joined: Sat 10 Jul 2010 06:47

Re: Demo(s) for Services?

Post by bzwirs » Mon 25 Feb 2013 23:11

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

AndreyZ

Re: Demo(s) for Services?

Post by AndreyZ » Tue 26 Feb 2013 11:28

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.

Post Reply