Understanding Locks/Cursors

Ruslan Zasukhin sunshine at public.kherson.ua
Sun Mar 28 09:05:09 CST 2004


On 3/28/04 7:47 AM, "mdeh at earthlink.net" <mdeh at earthlink.net> wrote:

> Name:      
> 
> Question regarding: v4rb
> 
> Ruslan,
> I know this has been asked many times, but I am still somewhat unclear on
> Locks, depsite having read all the info in the documentation and the
> discussion.

> Is this correct? 

> Provided the Cursor location is &#34;Server&#34; and the
> lock-type is &#34;Read-Write&#34;, a single cursor physically locks a record
> on a Table (if it is one table).

Yes, more correctly -- it lock all found records.


> And you say this is the reason you CAN do
> updates, deletes etc.

Not very correct.
We need locks to prevent conflicts between SEVERAL users/cursors.

> But what if the cursor has selected a Record from more
> than one table? 

In this case, cursor always is READ ONLY.
And it will set ReadOnly locks on records in each table.
This is needed to prevent other users from modifications of records which
read this cursor now.

> Does the Cursor lock ALL the tables, unitl it releases them?

Yes, but not the whole tables. Just found records.

> So can I then say this as a general statement? The best way to update, delete
> etc is to have the Cursor represent ONE table,

Exactly!

> then just do the updates and deletes.

yes

> So having multiple Cursors(independent) open at one time would NOT
> allow any changes from ANY cursors as we are breaking the &#34;single Cursor
> to single Table &#34; at one time rule?
> TIA

Not very correct.

Each cursor should try lock as few records as possible!

Then you can have 10 cursors which all select and lock different records
from the same table. Then each cursor will be able modify its records.


---------
Exists another way --- we can name it "More SQL way".
It is used widely in mySQL for example.

You get result of query as cursor with No locks.
And you send SQL commands UPDATE, INSEERT, DELETE if you need change
something. But to see changes you must rebuild cursor each time.
As for me not very nice

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list