Locking question
    Ruslan Zasukhin 
    ruslan_zasukhin at valentina-db.com
       
    Mon Dec 13 09:38:03 CST 2010
    
    
  
On 12/12/10 6:43 PM, "F. Kneubuehl" <f.kneubuehl at ysd.ch> wrote:
Hi Fabian,
> I need to solve a simple scenario (a mail slot system):
>  
> Client A:
>   Must  read a textbuffer from a row and set this to NULL
>  
> Other clients:
>   Should wait for Client A until finished with these 2 steps, then write data
> to the same textbuffer
  
> My solution:
>   Client A:
>   Cursor = SELECT textbuffer FROM myTable with a ServerSideCursor an
> ReadWriteLock
>   UPDATE myTable SET textbuffer=NULL
>   Cursor = Nothing
Well, in Valentina DB,you no need send UPDATE command.
You can do just
    curs.Field( "textBuffer" ).setBlank()           << make it NULL
    curs.UpdateRecord()
Record locks are established by cursor.
And you should use VCursor API to modify records now.
  
>   Other Clients:
>   DO
>       Cursor = SELECT textbuffer FROM myTable with a ServerSideCursor an
> ReadWriteLock
>   LOOP UNTIL DBError=0
>   UPDATE myTable SET textbuffer=AnyData
Same as above.
>   Cursor = Nothing
  
> This approach seems to work, but because the process runs on a random fashion
> with a 200ms timer I am not sure if this is the right and stable way. Any
> client can act as Client A¹ and Other Clients¹.
>  
> Any comment would be helpful!
-- 
Best regards,
Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc
Valentina - Joining Worlds of Information
http://www.paradigmasoft.com
[I feel the need: the need for speed]
    
    
More information about the Valentina
mailing list