Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

locks inside stored procedures

$
0
0
Hi,
I have 2 stored procedures that I call from CLI (I work with DB2 ESE 10.1 for LUW).

In proc1 I have

----
select x into myvar from TABLE;
IncrementFunction(myvar); --here myvar is incremented following some logic
update TABLE set x= myvar;
----

In proc 2 I have

-------
update TABLE set x= y;
select x into myvar from TABLE;
-------

The procedures can be called from within multiple processes so I would like the operations to be serialized.
I use autocommit=true from CLI, what else should I care about to reach what I want?
To be clearer I make an example in case 2:
I have process1 invoking proc2 --- TABLE is updated with val1
I have process2 invoking proc2 --- TABLE is updating with val2
process1 selects and gets val2 -- is it a possible error? how can I avoid it?

Thanks

Viewing all articles
Browse latest Browse all 13329