Rajat Sharma
Member
Hello everyone, hope you all are doing well.
Initially I have no idea regarding how transaction works in progress but now I started working and playing with them, I have few queries regarding transaction:
1. In FOR EACH loop, each iteration comes as an individual transaction. So for second iteration of FOR EACH loop, how lock table and .BI files entries are maintained for previous transaction. Either every current transaction delete the previous entry or append it (I thinks transaction deletes previous entry, please confirm).
For ex:
I know this transaction (mentioned below) works slow because each record is updated in database as a single record. But how .BI and lock table entries are maintained here.
2. If I put DO TRANSACTION loop around this FOR EACH loop (mentioned above) then it becomes ALL or NOTHING kind of stuff and all the changes occurred in FOR EACH loop are written to database at the end of the DO TRANSACTION(as a single transaction). So before writing them into database, where are these updated record resides, I thing they become part of temporary memory. Please confirm.
I read that in DO TRANSACTION case that, lock table and BI entries are very heavy. So how they are maintained in this case?
3. In the example below, if transaction halts in between then neither the order instruction nor name of the customer are updated.
If I put DO TRANSACTION around FIND FIRST (please refer below code for this) then I could prevent myself from this situation. But is the right solution for this problem, because I studied about REPEAT loop that it takes one transaction for each iteration of the loop and we don’t need to worry about lock table overflow problem as well. I tried using REPEAT in this situation but unable to find right approach of using that.
For ex:
As far as I understand, progress starts transaction whenever we write EXCLUSIVE-LOCK or when we UPDATE or WRITE something to database or when we use TRANSACTION keyword with DO or FOR EACH or REPEAT block.
So Here, I am not able to understand the meaning of TRANSACTION blocks. As per the documentation, FOR EACH, REPEAT and PROCEDURE as transaction blocks (why, are they going to start the transaction or what) and DO is not a transaction block (why). I tried many things between theses blocks but I didn’t find anything different.
Please Suggest.
Thanks & Regards!
Rajat.
Initially I have no idea regarding how transaction works in progress but now I started working and playing with them, I have few queries regarding transaction:
1. In FOR EACH loop, each iteration comes as an individual transaction. So for second iteration of FOR EACH loop, how lock table and .BI files entries are maintained for previous transaction. Either every current transaction delete the previous entry or append it (I thinks transaction deletes previous entry, please confirm).
For ex:
I know this transaction (mentioned below) works slow because each record is updated in database as a single record. But how .BI and lock table entries are maintained here.
Code:
FOR EACH customer where customer.country = “something”:
Balance = Balance * 5.
END.
2. If I put DO TRANSACTION loop around this FOR EACH loop (mentioned above) then it becomes ALL or NOTHING kind of stuff and all the changes occurred in FOR EACH loop are written to database at the end of the DO TRANSACTION(as a single transaction). So before writing them into database, where are these updated record resides, I thing they become part of temporary memory. Please confirm.
I read that in DO TRANSACTION case that, lock table and BI entries are very heavy. So how they are maintained in this case?
3. In the example below, if transaction halts in between then neither the order instruction nor name of the customer are updated.
Code:
FIND FIRST customer WHERE balance >= “something” EXCLUSIVE-LOCK.
IF AVAILABLE customer THEN
UPDATE name.
RUN update_order.
PROCEDURE update_order:
FOR EACH order of customer:
UPDATE instruction.
END.
END PROCEDURE.
If I put DO TRANSACTION around FIND FIRST (please refer below code for this) then I could prevent myself from this situation. But is the right solution for this problem, because I studied about REPEAT loop that it takes one transaction for each iteration of the loop and we don’t need to worry about lock table overflow problem as well. I tried using REPEAT in this situation but unable to find right approach of using that.
For ex:
Code:
DO TRANSACTION:
FIND FIRST customer WHERE balance >= “something” EXCLUSIVE-LOCK.
IF AVAILABLE customer THEN
UPDATE name.
END.
RUN update_order.
PROCEDURE update_order:
FOR EACH order of customer:
UPDATE instruction.
END.
END PROCEDURE.
As far as I understand, progress starts transaction whenever we write EXCLUSIVE-LOCK or when we UPDATE or WRITE something to database or when we use TRANSACTION keyword with DO or FOR EACH or REPEAT block.
So Here, I am not able to understand the meaning of TRANSACTION blocks. As per the documentation, FOR EACH, REPEAT and PROCEDURE as transaction blocks (why, are they going to start the transaction or what) and DO is not a transaction block (why). I tried many things between theses blocks but I didn’t find anything different.
Please Suggest.
Thanks & Regards!
Rajat.