<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br>Hi François,<br><br>(Ivan just responded with what I was thinking)<br><br>1) When talking to vServer we only use SQL<br>2) you should make it more clear what 'updating 5000 records' means. As long as it is 1 statement (Ivan -> atomic) you would just give the update statement and be done with it. No way another client can intervene.<br>3) if the update consists of more complex (multiple) statements you can write a stored procedure that will run , when called, as 1 statement.<br>4) if you don't want to move your business logic into a stored procedure you can write your own locking mechanism that every client will check before attempting to modify records (table properties could be used for that , or temp fields or …)<br><br>HTH<br><br>Bart<br>On 09 Oct 2013, at 08:21, Ivan Smahin <<a href="mailto:ivan_smahin@paradigmasoft.com">ivan_smahin@paradigmasoft.com</a>> wrote:<br><br><blockquote type="cite">Hi,<br><br>On Oct 8, 2013, at 7:38 PM, François Van Lerberghe <<a href="mailto:frvanlerberghe@gmail.com">frvanlerberghe@gmail.com</a>> wrote:<br><br><blockquote type="cite">As nobody answer my question, let me post it again :<br><br>I have a function (RealBasic/Xojo method) where I update every record of a<br>table (5000 records). In order to do that, I make a VCursor with<br>EVLokType.kReadWrite on the whole table.<br>At the end of this function , I call another function to update a few<br>records (50) of that same table. This update is in another function because<br>it is called by some other places of the project. How must I deal with the<br>records locking in this second Vcusor using the same table, but not the same<br>records ?<br><br>1) If I nil the first Vcursor (locking the whole table) before create the<br>second, locking the needed records, I have a risk (very low I know, but that<br>exist) that, just before I create my second Vcursor, another user lock some<br>records of that table, reading or writing incorrect data and stopping me to<br>complete the work.<br><br>2) Must I keep the first Vcursor ensuring that nobody can modify the table<br>and create the second with kNoLock ? Is it safe to update the records in<br>this second Vcursor ?<br><br>3) I see a third option : Keeping the first cursor. I pass this Vcursor as<br>parameter to iterate, test each record and update the records that meet some<br>condition. I don't like this option as<br>- I prefer sending a second SQL query to retrieve the needed records rather<br>than iterate and test each record<br>- this second function is called by some other places of the project<br><br>I prefer the second option if it is safe. Could you be kind enough to give<br>me your advice on this ?<br></blockquote><br><br>All that ways are possible.<br>If you prefer the second way - no problem to use it.<br>The only thing is - when you use kReadWrite cursor - it means nobody else will be able to create another RW/RO cursor over the same record (sub)set.<br>But that records are still available for updating via NoLock cursors or directly (using I_Table interface).<br><br>I think you need something like "atomic" peace of your business logic - do few updates against some data without a chance to be interrupted by another client.<br>I would suggest to move it all into some stored procedure and call that sp from your app.<br><br><br>-- <br>Best regards,<br>Ivan Smahin<br>Senior Software Engineer<br>Paradigma Software, Inc<br>Valentina - The Ultra-Fast Database<br><a href="http://www.valentina-db.com/">http://www.valentina-db.com</a><br><br>_______________________________________________<br>Valentina mailing list<br><a href="mailto:Valentina@lists.macserve.net">Valentina@lists.macserve.net</a><br><a href="http://lists.macserve.net/mailman/listinfo/valentina">http://lists.macserve.net/mailman/listinfo/valentina</a></blockquote></body></html>