Named user lock facility in IDS?
Posted in 2007
Topics: General Discussion
I wonder if someone could comment on if Informix IDS has a named user locking facility. I'm looking for the ability to lock things on the database server without being restricted by tables/rows/transactions etc. I would like to use this for all sorts of things within applications where controlled access is required to a given resource, i.e. access to a file on a filesystem,, I was looking at Oracle recently and noticed it includes a facility like this in a package called DBMS_LOCK. See http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lock.htm for further info. Any thoughts on how to achieve something similar with Informix IDS would be most welcome! Cheers, David
David N. Heydon wrote:
> I wonder if someone could comment on if Informix IDS has a named user
> locking facility. I'm looking for the ability to lock things on the database
> server without being restricted by tables/rows/transactions etc. I would
> like to use this for all sorts of things within applications where
> controlled access is required to a given resource, i.e. access to a file on
> a filesystem,,
>
> I was looking at Oracle recently and noticed it includes a facility like
> this in a package called DBMS_LOCK. See
> http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lock.htm
> for further info.
>
> Any thoughts on how to achieve something similar with Informix IDS would be
> most welcome!
>
> Cheers,
>
> David
>
>
Create a table call is something like "lock_table". Make it "lock mode
row".
create table lock_table {
lock_name varchar(255) primary key,
hold_lock integer
} lock mode row;
To 'allocate a lock', simply insert a row into the lock_table.
To set the lock "update lock_table set hold_lock = hold_lock + 1 where
lock_name = "my lock";
To release the lock - commit.