locking rows table rows 
Author Message
 locking rows table rows
Hello,
I have been searching for some sample C code on how to lock rows in tables
before update or delete.
could anybody help.
Thanks,

--
Alan



Mon, 16 Aug 2004 13:19:25 GMT
 locking rows table rows

Hi,

Firstly you have to set autocommit off mode, then to lock table rows execute
SELECT ... FOR UPDATE statement.

Best regards, Dmitry
--

http://www.ispirer.com/products - Database migration software for IBM DB2
and Oracle.


Quote:
> Hello,
> I have been searching for some sample C code on how to lock rows in tables
> before update or delete.
> could anybody help.
> Thanks,

> --
> Alan



Mon, 16 Aug 2004 21:05:07 GMT
 locking rows table rows
Alan,

If you're trying to lock individual rows with SQL calls, you can't do
it.  You can only lock a full table if necessary.

However, DB2 will lock rows for you when you perform a SELECT, UPDATE,
etc., How much will be locked will depend on your isolation level.
These rows are then locked until you issue a COMMIT or ROLLBACK.

You can heck the documentation on isolation levels for more information
on the exact performance.  Or, if you are trying to solve a specific
problem you can post more details here.

Quote:

> Hello,
> I have been searching for some sample C code on how to lock rows in tables
> before update or delete.
> could anybody help.
> Thanks,

> --
> Alan

--
====================================
To reply, delete the 'x' from my email

Jerry Stuckle
JDS Computer Training Corp.

====================================



Mon, 16 Aug 2004 22:32:32 GMT
 locking rows table rows
That's right. I think U have to declare the cursor  with the clause
"for update of (column name) and then use the "where current of ...
(cursor name)".
I don't know if U can declare for update of a column declared in an
unique index or if U can delete the row using this clause.
Bye

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG



Mon, 16 Aug 2004 23:12:58 GMT
 locking rows table rows

Quote:

> Alan,

> If you're trying to lock individual rows with SQL calls, you can't do
> it.  You can only lock a full table if necessary.

> However, DB2 will lock rows for you when you perform a SELECT, UPDATE,
> etc., How much will be locked will depend on your isolation level.

Yes, db2 will take care of this, the lock mode, lock status, lock duration, ...
according to the isolation level you use.

Quote:

> These rows are then locked until you issue a COMMIT or ROLLBACK.

Except "with hold".
Quote:

> You can heck the documentation on isolation levels for more information
> on the exact performance.  Or, if you are trying to solve a specific
> problem you can post more details here.


> > Hello,
> > I have been searching for some sample C code on how to lock rows in tables
> > before update or delete.
> > could anybody help.
> > Thanks,

> > --
> > Alan

> --
> ====================================
> To reply, delete the 'x' from my email

> Jerry Stuckle
> JDS Computer Training Corp.

> ====================================



Tue, 17 Aug 2004 12:16:19 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Row lock automagically being escalated to Table Locks

2. table-level lock or row-level lock

3. Better Perf: 1 table with 25,000,000 rows or 10 tables with 2,500,000 rows

4. Deleting rows from one table and adding those rows to another table at the same time

5. Error: Row handle referred to a deleted row or a row marked for deletion

6. Row handle referred to a deleted row or a row marked for deletion

7. Updating a Table by selecting row by row

8. Opening a table and looping through it row by row

9. Combing multiple row data into one row in another table

10. combining rows from a table in to one row

11. How to transactionally insert a row and rows into parent and child table

12. Moving current record to match row in SQL result table row


 
Powered by phpBB® Forum Software