Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread RESTORE fails due to LOck.
Fri, Jul 20 2018 3:02 AMPermanent Link

Ian Branch

Avatar

Hi Team,
   Working with Backup & RESTORE. BACKUP seems to work fine the Data is in the Store.
   When I go to RESTORE per the following:
{sql}
procedure TForm3.btnRestoreClick(Sender: TObject);
begin
 //
 Screen.Cursor := crHourglass;
 //
 DBC1.Connected := False;
 //
 DBS1.Execute('RESTORE DATABASE "DBiWorkflow" FROM "DBiWorkflow-Backup-' + Engine.DateToSQLStr(Date) + '" IN STORE
"Backups" INCLUDE CATALOG');
 //
 MessageBeep(MB_ICONINFORMATION);
 //
 tqBackup.Open;
 //
 Screen.Cursor := crDefault;
 //
 MessageDlg('DBiWorkflow database restore completed.', mtInformation, [mbOK], 0);
 //
end;
{sql}
   I get an error # 300 - "Cannot lock the Database DBiWorkflow for exclusive access"
   As at the DBS1.Execute('...  only the TEDBEngine & TEDBSession are 'Active'.
   What else could be locking the database?

Regards & TIA,
Ian
Fri, Jul 20 2018 3:22 AMPermanent Link

Malcolm Taylor

Hi Ian

I had an issue lke that a long time ago .. and I have a note in my code:

     // added the next line because some restores fail otherwise..
     // .. don't know why
     DM.EDBEngine1.Close;

before running my Session.Execute('RESTORE .....      

At a guess there is still something else econnected.  Closing the
Engine 'makes sure'.

Maybe someone can tell me a better 'cludge'.  <bg>
Fri, Jul 20 2018 3:46 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


Is there another user active, do you have the database open in EDBManager?

If the above is OK what about setting the engine inactive rather than DBC1.Connected := False;

Roy Lambert
Fri, Jul 20 2018 4:38 AMPermanent Link

Ian Branch

Avatar

Hi Malcolm,
   Yep, that did it Tks.
   The Configuration.Backups table is being displayed in a DBGrid.
   After the Restore operation I do the following:
{code}
 DBC1.Open;      << This should re-open the database.
 tqBackup.Open;      << This should re-open configuration.backups.
 DBGrid1.Refresh;   <<  Just in case. Smile
{code}
   I don't get any errors, nor do I get the Backups data displayed. Frown
   Any thoughts?
Regards & Tks,
Ian
Fri, Jul 20 2018 4:40 AMPermanent Link

Ian Branch

Avatar

Roy Lambert wrote:

> Is there another user active, do you have the database open in EDBManager?
>
Nope.  Only one table and that is for configuration.engine nd was being closed by DBC1.Close;

> If the above is OK what about setting the engine inactive rather than DBC1.Connected := False;
Yep.  That did it.

Regards,
Ian
Fri, Jul 20 2018 5:20 AMPermanent Link

Malcolm Taylor

Ian, not quite sure what you are saying, but ..

After the Restore, and having stopped the Engine, you will have to
restart things much as you will be doing when launching your program in
the first place.

Malcolm
Fri, Jul 20 2018 5:36 AMPermanent Link

Ian Branch

Avatar

Malcolm wrote:

> After the Restore, and having stopped the Engine, you will have to
> restart things much as you will be doing when launching your program in
> the first place.

Yup.  This did it.
{code}
 DBS1.Execute('SET BACKUPS STORE TO "Backups"');
 tqBackup.Open;
 DBGrid1.Refresh;
{code}

Regards & Tks,
Ian
Mon, Jul 23 2018 12:06 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ian,

<< I get an error # 300 - "Cannot lock the Database DBiWorkflow for exclusive access"
As at the DBS1.Execute('...  only the TEDBEngine & TEDBSession are 'Active'.
What else could be locking the database? >>

It could be a temporary database connection:

https://www.elevatesoft.com/manual?action=viewmethod&id=edb2&product=rsdelphiwin32&version=10T&comp=TEDBSession&method=DropConnections

If you have any tables, queries, or scripts in your session(s) that reference databases by name, but don't reference an *explicit* TEDBDatabase instance, then EDB will create a temporary database for you and will be subject to the behavior described in the above link.

Tim Young
Elevate Software
www.elevatesoft.com
Image