Skip to content

SBME and record lock

Forums Forums SIMPOL Programming SBME and record lock

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #250
    Kurt Hansen
    Participant

    Hi I have a problem saving records in a SBME database. Attempts to save records raises the error message 903 “Not locked” I have tried the following combinations: File Lock Record lock Error code ========= =========== ========== “” “Exclusive” 903 (not locked) “Exclusive” “” 903 “Exclusive” “Exclusive” 908 (Already locked) What is the right way to manage lock types in SBME? A am testing sbme in a application witch runs without problems connected to a PPCS server, with as few changes as possible: Inialisation: ============ …. // SBME: fil =@ sbme1.new(“adr.sbm”,”O”, err ) adr =@ fil.opentable(“ADR”, .nul, err ) adr.lock (“”, err ) :// or…??? …. Save: ==== … … err=0 // Lock // ppcs: if rec.type == ppcstype1record rec =@ rec.selectcurrent(idx ,.true , err, errtxt, 500000, 5000000) end if // SBME: if rec.type == sbme1record rec.selectcurrent(idx,””exclusive””,err) end if … … // Save: //PPCS: if rec.type == ppcstype1record rec!ID = newid rec.save(.false, err, errtxt, 1000000, 5000000) end if //SBME: if rec.type == sbme1record rec!ID = newid rec.save(“exclusive”, err) :// or ???????? end if … … Kurt Hansen

    #1835
    Michael
    Keymaster

    Kurt Hansen wrote:
    > Hi I have a problem saving records in a SBME database. Attempts to
    > save records raises the error message 903 "Not locked"
    >
    > I have tried the following combinations:
    >
    > File Lock Record lock Error code
    > ========= =========== ==========
    > "" "Exclusive" 903 (not locked)
    > "Exclusive" "" 903
    > "Exclusive" "Exclusive" 908 (Already locked)
    >
    > What is the right way to manage lock types in SBME?
    >
    > A am testing sbme in a application witch runs without problems
    > connected to a PPCS server, with as few changes as possible:
    >
    > Inialisation:
    > ============
    > ….
    > // SBME:
    > fil =@ sbme1.new("adr.sbm","O", err )
    > adr =@ fil.opentable("ADR", .nul, err )
    > adr.lock ("", err ) :// or…???
    > ….
    >
    > Save:
    > ====
    > …
    > …
    > err=0
    > // Lock
    > // ppcs:
    > if rec.type == ppcstype1record
    > rec =@ rec.selectcurrent(idx ,.true , err, errtxt, 500000, 5000000)
    > end if
    > // SBME:
    > if rec.type == sbme1record
    > rec.selectcurrent(idx,""exclusive"",err)
    > end if

    The problem is that you are not locking the object that you used for
    selection. Your code needs to do this:

    type(db1record) rec2

    if rec.type == ppcstype1record
    rec2 =@ rec.selectcurrent(idx ,.true , err, errtxt, 500000, 5000000)
    else if rec.type == sbme1record
    rec2.selectcurrent(idx,""exclusive"",err)
    end if

    if rec2 !@= .nul
    rec2!ID = newid
    if rec.type == ppcstype1record
    rec2.save(error=err, retry=1000000, timeout=5000000)
    else
    rec2.save(error=err)
    if err == 0
    rec2.table.sbme.commit(error=err)
    else
    rec2.table.sbme.rollback(error=err)
    end if
    end if
    end if

    At this point rec2 and rec both point to the same record, but the
    information in rec is out of date, whereas rec2 is current (and also not
    locked since it was not requested during the save operation.

    BTW, Kurt your email server is not accepting email. Can you contact me
    and provide a different email address?

    Ciao, Neil

    #1836
    Kurt Hansen
    Participant

    Neil Robinson skrev:
    > Kurt Hansen wrote:
    >> Hi I have a problem saving records in a SBME database. Attempts to
    >> save records raises the error message 903 "Not locked"
    >>
    >> I have tried the following combinations:
    >>
    >> File Lock Record lock Error code
    >> ========= =========== ==========
    >> "" "Exclusive" 903 (not locked)
    >> "Exclusive" "" 903
    >> "Exclusive" "Exclusive" 908 (Already locked)
    >>
    >> What is the right way to manage lock types in SBME?
    >>
    >> A am testing sbme in a application witch runs without problems
    >> connected to a PPCS server, with as few changes as possible:
    >>
    >> Inialisation:
    >> ============
    >> ….
    >> // SBME:
    >> fil =@ sbme1.new("adr.sbm","O", err )
    >> adr =@ fil.opentable("ADR", .nul, err )
    >> adr.lock ("", err ) :// or…???
    >> ….
    >>
    >> Save:
    >> ====
    >> …
    >> …
    >> err=0
    >> // Lock
    >> // ppcs:
    >> if rec.type == ppcstype1record
    >> rec =@ rec.selectcurrent(idx ,.true , err, errtxt, 500000, 5000000)
    >> end if
    >> // SBME:
    >> if rec.type == sbme1record
    >> rec.selectcurrent(idx,""exclusive"",err)
    >> end if
    >
    > The problem is that you are not locking the object that you used for
    > selection. Your code needs to do this:
    >
    > type(db1record) rec2
    >
    > if rec.type == ppcstype1record
    > rec2 =@ rec.selectcurrent(idx ,.true , err, errtxt, 500000, 5000000)
    > else if rec.type == sbme1record
    > rec2.selectcurrent(idx,""exclusive"",err)
    > end if
    >
    > if rec2 !@= .nul
    > rec2!ID = newid
    > if rec.type == ppcstype1record
    > rec2.save(error=err, retry=1000000, timeout=5000000)
    > else
    > rec2.save(error=err)
    > if err == 0
    > rec2.table.sbme.commit(error=err)
    > else
    > rec2.table.sbme.rollback(error=err)
    > end if
    > end if
    > end if
    >
    > At this point rec2 and rec both point to the same record, but the
    > information in rec is out of date, whereas rec2 is current (and also not
    > locked since it was not requested during the save operation.
    >
    > BTW, Kurt your email server is not accepting email. Can you contact me
    > and provide a different email address?
    >
    > Ciao, Neil

    Thanks problem solved!
    (You are right about the working with the same record,
    I've forgot an rec =@ in the rec.selectcurrent statement)

    My email address ku**@**6.dk works again

    Ciao, Kurt

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.