Re: Select for update in SPL
Posted in 2004
Jonathan Leffler <jleffler@earthlink.net> wrote in message news:<jNdXc.13511$3O3.7105@newsread2.news.pas.earthlink.net>...
> Aleksandr Shneyderman wrote:
>
> > I am trying to put a promotable lock on a table row inside a stored
> > procedure and for some reason SPL does not allow me to use SELECT FOR UPDATE
> > ...
> >
> > Any suggestions? (Informix 7.31)
>
> Post the code - I'm pretty sure SPL does allow FOR UPDATE.
It doesn't allow "for update" clause. I wasted some good time trying
to make it do it and it was very frustrating. I think that you
actually have to do an update to get an update lock in spl. So you
could do the following to lock the record
update table_test set test_field = test_field where current of<cursor_name>;
See this doesn't actually change any data but marks it as updated. It
should hold the lock until after the foreach loop. I don't know if it
will help but you might want to pick a field that is not in an index
or part of a trigger in case informix doesn't check to see if it is
the same value before "updating" the index or firing the trigger.
Of course there may be an even more elegant solution based on what
problem you are actually trying to solve.