tom_pim
25th September 2009, 02:17
I need to generate the next bptmm130.seqn value for a given employee-year-period so I can insert a record. Using the DAL would be the optimum choice, however I cannot do this because of a recursion error. To explain breifly, the code automates the creation of a second hours accounting record when certain types of labor entries are made in hours accounting (bptmm1130m000).
I have code to get the next seqn value but I'm concerned it is not safe for concurrent transactions --- that is two different people keying in records at the same time:
| have to get next seqn value
| is this safe for concurrent operations?
select max(bptmm130.seqn):max.seqn
from bptmm130
where bptmm130._index1 = {:i.emno, :bptmm130.year, :bptmm130.peri}
as set with 1 rows
selectdo
bptmm130.seqn = max.seqn + 1
selectempty
bptmm130.seqn = 1
endselect
then I go on w/ db.insert() later
All of this is happening in the ue.after.after.save.object() method of a user-exit DAL for bptmm130. So I'm assuming (and it appears) that db.retry/commit is being handled outside of my code (by 4GL engine?).
My questions are: is the code the way its written safe for concurrent transactions? If not, how can I change it so it is?
Thanks in advance,
-Tom
I have code to get the next seqn value but I'm concerned it is not safe for concurrent transactions --- that is two different people keying in records at the same time:
| have to get next seqn value
| is this safe for concurrent operations?
select max(bptmm130.seqn):max.seqn
from bptmm130
where bptmm130._index1 = {:i.emno, :bptmm130.year, :bptmm130.peri}
as set with 1 rows
selectdo
bptmm130.seqn = max.seqn + 1
selectempty
bptmm130.seqn = 1
endselect
then I go on w/ db.insert() later
All of this is happening in the ue.after.after.save.object() method of a user-exit DAL for bptmm130. So I'm assuming (and it appears) that db.retry/commit is being handled outside of my code (by 4GL engine?).
My questions are: is the code the way its written safe for concurrent transactions? If not, how can I change it so it is?
Thanks in advance,
-Tom