Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
Would you like to see a separate forum on Baanboard for the ION product?
No
13%
Yes
87%
Total votes: 90

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 24th July 2004, 05:58
fcd123 fcd123 is offline
Newbie
 
Join Date: Jul 2004
Posts: 1
fcd123 is on a distinguished road
Baan: 4 - DB: Informix - OS: Unix
Question Table locking problem

There is a table which stores the last control number for a specific control key.First I read this table to get the last generated number. After this I check within the same table which contains say order no,print date,file no.etc., whether a records exists for the order no. If the record exists I update the new values else I insert the record. When more than two users are using this session simultaneously, the last number is not picked up,probably because of the locking by an update of this table which is at the same time being run by another user. Hence the new number is not generated. Is there any way of locking/releasing the lock of the table ?

I am also attaching the logic :-
Code:
if tssma301.tfrm = tcyesno.yes then
        reprint = "REPRINT"
                check.reprint.tsgal045()
        else
        reprint = ""
                pr.fino=0
                get.franc.code()                               
                if tmp.suno <> ""
                then                                            
                        check.last.fino()
                        check.fresh.print.tsgal045()
                else
                        write.file()                            
                endif
        endif

function get.franc.code()                              
{
        select  tsgal046.*
        from    tsgal046
        where   tsgal046._index1 = {:tssma301.cctp}
        and     (tsgal046.f_care <= :tssma301.care and
                 tsgal046.t_care >= :tssma301.care)
        as set with 1 rows
        selectdo
                tmp.suno = tsgal046.suno
        endselect
}

function check.fresh.print.tsgal045()
{
        select  tsgal045.*
        from    tsgal045 for update
        where   tsgal045._index2 = {:tssma301.orno}
        selectdo
                update.rec()
        selectempty
                insert.rec()
        endselect
}
function insert.rec()
{
        tsgal045.suno = tmp.suno
        tsgal045.orno = tssma301.orno
        pr.fino = pr.fino + 1
        tsgal045.fino = pr.fino
        tsgal045.login = login.name
        tsgal045.cctp = tssma301.cctp                   
        tsgal045.prdt = date.num()
        tsgal045.care = tssma301.care                   
        tsgal045.cloc = tssma301.cloc
        db.insert(ttsgal045,db.retry,db.skip.dupl)
        commit.transaction()
}

function update.rec()
{
        tsgal045.suno = tmp.suno
        pr.fino = pr.fino + 1
        tsgal045.fino = pr.fino
        tsgal045.login = login.name
        tsgal045.cctp = tssma301.cctp                   
        tsgal045.prdt = date.num()
        tsgal045.care = tssma301.care                   
        tsgal045.cloc = tssma301.cloc
        db.update(ttsgal045,db.retry)
        commit.transaction()
}

Last edited by mark_h : 25th July 2004 at 02:34.
Reply With Quote
  #2  
Old 25th July 2004, 02:38
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Louisville, KY, USA
Posts: 5,970
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
The only thing I see is you say db.retry in the insert and update, but I do not see where you set the db.retry.point() at - I would add it before the select tsgal045 for update statement.

Mark
Reply With Quote
  #3  
Old 25th July 2004, 14:42
toolswizard toolswizard is offline
Senior Member
 
Join Date: Aug 2001
Location: USA
Posts: 281
toolswizard is on a distinguished road
Baan: 4c4, 50b, 50c, ERP ln - DB: Informix, Oracle, Sql - OS: Unix, NT, AIX
You can also apply an application lock. This is a logical lock between co operating programs. You would set the lock before reading the next available number, validate, increment, and same the new value, then release the lock as you continue processing. The other user would attempt to do the same, and you can instruct the session to wait until the lock is freed before continuing. Check most of the order processing sessions which use the first free number table, and the function source file for more information.
Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
copy records c_siek Tools Development 9 18th June 2004 15:43
Table update problem Debdas Banerjee Tools Development 3 30th October 2003 19:10
Problem with one table Haggis Tools Development 9 30th January 2002 18:18


All times are GMT +2. The time now is 07:25.


©2001-2013 - Baanboard.com - Baanforums.com