Apply locks to a row or a table
Posted in 2000
Topics: Server Administration
Hello !!! I have an Informix Universal Server 9.14 engine, with one database with a lot of tables. I access to these tables trough the DBACCESS utility and/or a web based application. I need to know what commands I have to use to set a lock to a row of a given table or to an entire table, using the DBACCESS. And then I need the commnads to unlock them. Remark: my database has logging mode. Thanks !!! Alejandro Cabrera Obed E-mail: sisdis@tournet.com.ar ICQ#95838645 Bs. As. - Argentina
<paste from dbaccess help facility>
LOCK TABLE table-name IN {SHARE | EXCLUSIVE} MODE
SET ISOLATION TO {DIRTY READ | COMMITTED READ
| CURSOR STABILITY | REPEATABLE READ}
UNLOCK TABLE table-name
<end paste>
HTH
Brett Randall
Alejandro Cabrera Obed wrote:
>
> Hello !!!
>
> I have an Informix Universal Server 9.14 engine, with one database with a
> lot of tables.
> I access to these tables trough the DBACCESS utility and/or a web based
> application.
> I need to know what commands I have to use to set a lock to a row of a given
> table or to an entire table, using the DBACCESS. And then I need the
> commnads to unlock them.
> Remark: my database has logging mode.
>
> Thanks !!!
>
> Alejandro Cabrera Obed
>
> E-mail: sisdis@tournet.com.ar
> ICQ#95838645
> Bs. As. - Argentina
Brett Randall wrote:
> <paste from dbaccess help facility>
>
> LOCK TABLE table-name IN {SHARE | EXCLUSIVE} MODE
This locks the whole table, of course. Locking individual rows is
harder. It can only be executed in the context of a transaction in a
database with logging.
> SET ISOLATION TO {DIRTY READ | COMMITTED READ
> | CURSOR STABILITY | REPEATABLE READ}
This allows a process to ignore, or not, any locks held by other
processes.
> UNLOCK TABLE table-name
This only works in a database without transactions; in a database with
transactions, you use COMMIT WORK or ROLLBACK WORK.
> <end paste>
> Alejandro Cabrera Obed wrote:
> > I have an Informix Universal Server 9.14 engine, with one database with a
> > lot of tables.
> > I access to these tables trough the DBACCESS utility and/or a web based
> > application.
> > I need to know what commands I have to use to set a lock to a row of a given
> > table or to an entire table, using the DBACCESS. And then I need the
> > commnads to unlock them.
> > Remark: my database has logging mode.
You probably don't want to lock rows or tables in a web based system;
the person who locks the row will go to lunch with the lock still in
place -- or go on holiday for a month. Locking rows with DB-Access is
hard; you have to modify or delete (or insert) the rows to create the
lock if the lock is to be exclusive. You can set isolation to
repeatable read to make sure noone else modifies the rows while you're
at it. You might experiment with a FOR UPDATE clause tacked onto the
end of a SELECT to see what locks are applied, but its getting tenuous;
DB-Access was not designed for that sort of use.
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"