Forums › Forums › SIMPOL Programming › SBME and record lock
- This topic has 2 replies, 2 voices, and was last updated 14 years, 2 months ago by Kurt Hansen.
- AuthorPosts
- February 27, 2010 at 3:20 pm #250Kurt HansenParticipant
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
February 28, 2010 at 1:56 pm #1835MichaelKeymasterKurt 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 ifThe 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 ifif 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 ifAt 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
March 1, 2010 at 8:13 am #1836Kurt HansenParticipantNeil 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, NeilThanks 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
- AuthorPosts
- You must be logged in to reply to this topic.