Re: Two processes accessing the same table.
Posted in 2004
Andrew Hardy wrote:
>
> I have a table which includes this:
>
> LOCK MODE ROW
>
> I open a cursor thus:
>
> SELECT reader, filename, readstatus FROM tableA WHERE filename
> = 'xxxxxx' FOR UPDATE>
> I execute next on this cursor compiling a list of readers with a particular
> readstatus.
>
> I then sleep before closing the cursor so I can test the behaviour of
> another process that accesses one of the same rows in the same table thus:
>
> EXEC SQL SET ISOLATION TO COMMITTED READ;
> UPDATE user_file_read_table SET readStatus = 2 WHERE reader = 'joblogs'
> AND fileName = 'xxxxxxx'>
> carry out some actions.....
>
> UPDATE user_file_read_table SET readStatus = 1 WHERE reader = 'joblogs'
> AND fileName = 'xxxxxxx'>
> My expoectation, given the locking status is that the actions will not get
> carried out until the first process stops sleeping and unlocks its cursor,
> but contrary to that the second process just sails on through.
>
> Any suggestions ?
An UPDATE cursor will only lock the currently fetched row. So presumably
you have the last row locked during your sleep. Did you actually update any
rows during the UPDATE cursor? It will also depend on your isolation level.
Cheers,
--
Mark.
+----------------------------------------------------------+-----------+
| Mark D. Stock mailto:mdstock@MydasSolutions.com |//////// /|
| Mydas Solutions Ltd http://MydasSolutions.com |///// / //|
| +-----------------------------------+//// / ///|
| |We value your comments, which have |/// / ////|
| |been recorded and automatically |// / /////|
| |emailed back to us for our records.|/ ////////|
+----------------------+-----------------------------------+-----------+
sending to informix-list