Locking tricks
Posted in 2000
Topics: General Discussion
This is a multi-part message in MIME format. --------------CC3590213299EDAECA140CFB Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Gurus, I have a query, is there a drastic way ( or even not a drastic one) of locking more than 1 row(s), let's say I want to lock the 10 records and the other 10 are lock by another. I'm already resorting to my last option, to use a temp table (please don't....). Thanks for the help. Regards, Jojo --------------CC3590213299EDAECA140CFB Content-Type: text/x-vcard; charset=us-ascii; name="ejmorale.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Jojo Morales Content-Disposition: attachment; filename="ejmorale.vcf" begin:vcard n:Morales;Jojo tel;work:830-58-40/42 x-mozilla-html:FALSE org:DHL Aviation Phils.;APME-OPS IT Development version:2.1 email;internet:ejmorale@apme-ops.dhl.com title:IT Contractual Developer note:/* These are my opinions, not my company's opinion */ adr;quoted-printable:;;12/F Urban Bank Plaza=0D=0APasong Tamo cor. Buendia;Makati;;;Phils. fn:Jojo Morales end:vcard --------------CC3590213299EDAECA140CFB--
First, please do not post HTML or MIME. This is a text only newsgroup.
Eduardo MORALES wrote:
> Hi Gurus,
>
> I have a query, is there a drastic way ( or even not a drastic one)
> of locking more than 1 row(s), let's say I want to lock the 10 records
> and the other 10 are lock by another. I'm already resorting to my last
> option, to use a temp table (please don't....).
The following is pseudo-4GL for using REPEATABLE READ Isolation and an
update cursor to hold locks on all fetched rows until the cursor is closed
and any transaction committed or rolled back.
SET ISOLATION REPEATABLE READ;
BEGIN WORK;
DECLARE a_cursor CURSOR FOR
SELECT ....
FROM ...
WHERE ....FOR UPDATE;
FOREACH a_cursor INTO ....
-- fetch, but do not necessarily update, each row to lock it
...
...
...
END FOREACH
-- Release all locks
COMMIT WORK;
The same can be done in ESQL/C.
Art S. Kagel