Subject | Re: database exclusive locking |
---|---|
Author | Adam |
Post date | 2005-07-03T23:21:15Z |
Attila,
It depends on what you mean by exclusive mode?
Embedded will lock the fdb to a single process (see Pavel's post),
but the same process can make multiple connections to the database
even on different threads.
You can put the db into offline mode (see Helen's post), however this
does not prevent SYSDBA and the owner from connecting.
Otherwise you can create a table yourself to manage it. Put a table
in place.
create table tblExclusive
(
ID integer;
);
commit;
insert into tblExclusive (id) values (1);
commit;
Now when your program loads, in a dedicated transaction run the
following query.
update tblExclusive set id=id;
This will put a row lock on that record. Set your transaction to be
no_wait, so that other instances of your application will receive an
exception immediately when they run this.
When your application exits you can simply rollback this transaction
(or commit it doesn't really matter in this case). This concept can
also be expanded to lock a single section of the application.
Adam
It depends on what you mean by exclusive mode?
Embedded will lock the fdb to a single process (see Pavel's post),
but the same process can make multiple connections to the database
even on different threads.
You can put the db into offline mode (see Helen's post), however this
does not prevent SYSDBA and the owner from connecting.
Otherwise you can create a table yourself to manage it. Put a table
in place.
create table tblExclusive
(
ID integer;
);
commit;
insert into tblExclusive (id) values (1);
commit;
Now when your program loads, in a dedicated transaction run the
following query.
update tblExclusive set id=id;
This will put a row lock on that record. Set your transaction to be
no_wait, so that other instances of your application will receive an
exception immediately when they run this.
When your application exits you can simply rollback this transaction
(or commit it doesn't really matter in this case). This concept can
also be expanded to lock a single section of the application.
Adam