Mutli insert/update by multi user at same time - unitofwork

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 03-Sep-2010 16:22:48   

Dear Support

I just need a hint to achieve the following with llblgen I have a table called monthlybill whose structure is as follows

TABLE : MONTHLYBILL

MONTHLYBILL_ID MONTH MEMBER_ID AMOUNT 1 SEPTEMBER 2010 1 0 2 OCTOBER 2010 1 0

EMPTY TABLE : MONTHLYBILLDETAIL

MONTHLYDETAIL_ID[SEQUENCE] MONTHLYBILL_ID[FK] LEDGER_ID MEMBER_ID AMOUNT

Now mutliple user action AT A TIME will be as follows

USER1

UPDATE MONTHLYBILL SET AMOUNT=AMOUNT+100 WHERE MONTHLYBILL_ID=1 INSERT INTO MONTHLYBILLDETAIL LEDGER_ID=1 MEMBER_ID=1 AMOUNT=100

USER2 UPDATE MONTHLYBILL SET AMOUNT=AMOUNT+500 WHERE MONTHLYBILL_ID=1 INSERT INTO MONTHLYBILLDETAIL LEDGER_ID=1 MEMBER_ID=1 AMOUNT=100 [ THIS SHOULD INFACT UPDATE SINCE LEDGER_ID=1 IS INSERTED BY FIRST USER]

INSERT INTO MONTHLYBILLDETAIL LEDGER_ID=2 MEMBER_ID=1 AMOUNT=250

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Sep-2010 23:25:06   

I see, but I don't understand what is the problem. I mean, Are you looking for concurrency control? Or Are you looking for a way the second action checks if it need to do an update or an insert?

David Elizondo | LLBLGen Support Team
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 04-Sep-2010 05:50:37   

daelmo wrote:

I see, but I don't understand what is the problem. I mean, Are you looking for concurrency control? Or Are you looking for a way the second action checks if it need to do an update or an insert?

Daelmo, you got it right. looking for a way the second action checks if it need to do an update or an insert. Because both user 1 and user2 will use the application on different PC's at a time and it is winform application

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Sep-2010 09:06:17   

This is a business case and should be handled in your code (Business Logic Layer). There you should check for a matching record before inserting, and if found update it with the required values and save it.

shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 06-Sep-2010 09:23:18   

Walaa wrote:

This is a business case and should be handled in your code (Business Logic Layer). There you should check for a matching record before inserting, and if found update it with the required values and save it.

Thanks Walaa if it is part business case, I will manage it