User33
16th August 2011, 10:46
Hello,
I had to make a compex report, so I needed to make a temporary table where I put all the data.
Program works correctly if only one user uses session, but there are confict if several users need to run some report.
I tried to uses appl.lock, and if works correctly.
Furthermore, I needed addiotional reports, so I made a new session, and I wanted to use the same temporay table.
Does anybody know how to use table lock in code?
Thank you for the help.
rahul.kolhe22
16th August 2011, 11:34
Hi,
You can use function db.lock.table (http://www.baanboard.com/programmers_manual_baanerp_help_functions_db_operations_db_lock_table) to lock the table. I have never used this function.
According to me, using application lock would be a more preferable in this case.
May be I would suggest you to set the application lock for the temporary table in both the sessions as soon as you start processing & release it when you finish your processing.
Or else you can even add two fields in it, 1st = session ID & 2nd = user ID.
Hope it helps you.
Regards,
--Rahul
mark_h
16th August 2011, 14:35
When I use a temporary table I use to include key fields to make the records unique - so not only can multiple users run the report, but the same user can run it multiple times. I used to include something like userid and process id as part of the key. Then you just need to make sure the records get cleaned up. I don't think I do this any where at this time - I know I have some temp tables, but not for users any more.
I have used appl.lock to make a session single user at a time. I just set a lock and do not remove it until the user exits. I don't think this is what you are looking for in this case. Yes - you can lock individual records or group of records, but you still need a key on the temp table that allows others to work or run the session - based off your post.
BaanInOhio
17th August 2011, 06:11
Ditto what Mark said, but I also add a date field to the record. The standard exit function for the session(s) using this table removes records created by the current user (by unique key including user & timestamp) and any records more than a week old by any user. This ensures that old records from an abnormal exit don't stay around too long.
If there aren't a lot of fields involved, you might want to look into using dynamic arrays and the QSS functions. I normally use dynamic arrays when reporting or calculating, temporary tables when the outcome is presented in an inquiry form.
User33
17th August 2011, 08:32
Thak you for your idea.
I already tried to do it the wayyou suggest, and it goes fine in most cases, but sometimes program does not unlock correctly, so I have to remove appl.lock manually. That's why I thought it might be better to use table lock, but I have never seen anything similar in any code.
Regards!
Hi,
You can use function db.lock.table (http://www.baanboard.com/programmers_manual_baanerp_help_functions_db_operations_db_lock_table) to lock the table. I have never used this function.
According to me, using application lock would be a more preferable in this case.
May be I would suggest you to set the application lock for the temporary table in both the sessions as soon as you start processing & release it when you finish your processing.
Or else you can even add two fields in it, 1st = session ID & 2nd = user ID.
Hope it helps you.
Regards,
--Rahul
User33
17th August 2011, 08:39
Thanks you all. I try to do this way.