JRussell
30th October 2002, 11:35
Hi,

I have a problem with Error 206, Record is not locked.

I will try to explain what I am doing: I am zooming from a session(A) to another session(B). In (B) I enter records and save. When I return to the main session (A) I want the sum of a field to be displayed in (A). To do this I have selected the table for session (B), read the corresponding records (like order header + lines would be linked), I total the field and I try to do a db.update and a commit.

I have read the other threads on this in the forums, but still a bit confused. I understand the problem is to do with commit interfering with standard code, but if I remove the commit I get the message "Transaction isn't on". I have placed my code below.

Could someone have a look at it and give me some advise???

Not sure how I could use after.update.db.commit???

Thanks for any help offered, very much appreaciated!!


after.zoom:
|*** returning the total downtime hours
temptotal = 0
temptotal2 = 0
wawti601.dthrstot = 0
db.retry.point()
select wawti611.*, wawti601.*
from wawti611, wawti601 for update
where wawti611.pono = :wawti601.pono
and wawti601.pono = :wawti601.pono
selectdo
temptotal = temptotal + wawti611.dthrsact
temptotal2 = temptotal2 + wawti611.changeov + wawti611.startup +
wawti611.nomat + wawti611.noop + wawti611.adjustmt + wawti611.projects
selecteos
wawti601.dthrstot = temptotal + temptotal2
wawti601.pdvolact = temp1
wawti601.overwgt = temp2
db.update(twawti601, DB.RETRY)
commit.transaction()
endselect

carice
30th October 2002, 12:03
1. What's the index of table wawti601 and wawti611?
2. You don't need to set wawti601.dthrstot = 0
3. Are you sure that in your session B , a commit.transaction is done? Maybe you can set a commit.transaction() before the db.retry.point().
4. I don't understand your where-clausule. Maybe you can put :wawti601.pono in a variable (before you go into your select) and use this variable. Are you sure your where clausule is right? (you want a link from the external variable to wawti601.pono to table wawti611 AND wawti601?

Paul P
30th October 2002, 12:14
Dear JRussell,

Just a thought; what if you perform the update of the total while still in the child session instead? For example, you can code them just before exiting with choice.end.session

Rgds,
Paul

JRussell
30th October 2002, 13:06
Hi Carice + Paul,

Carice, the code works fine. The correct records are selected and everything is updated. All fields are updated, error occurs when I exit the session. When I go back in all neccessary have been updated with the correct values.

This really is so confusing... and annoying.

I have commited in the child session.

Paul, I tried to update in the child but still get the record locking error......

This is going to drive me mental!!!!

:confused:

jvenderb
31st October 2002, 23:16
I don't know a answer to your question but you can encounter some problems with this code:
1. If the update fails the program returns to the db.retry.point() and starts all over again. But your variables are not set to zero and your totals will be doubled. To solve this:

temp1 = 0
temp2 = 0

db.retry.point()

if db.retry.hit()
temp1 = 0
temp2 = 0
endif

select statement
.....

2. You want to update the last selected record? The update is done in the selecteos. It doesn't matter which record is the last one? I ask this because you don't use an order by. So you can't be sure what is the last record. To solve this:

- First determine the totals (your code without the update stuff)
- Do a select on the table you want do update and select the record you want to update.

Code
db.retry.point()

(db.retry.hit is not needed anymore, totals are calculated)

select table.*
from table for update
where .....
as set with 1 rows
selectdo
db.update(table, db.retry)
commit.transaction()
endselect

Paul P
1st November 2002, 03:22
Dear JRussell,

If all the records in that particular part of the code are updated successfully, then could it be that the error 206 is for another table in another part of your code?

Rgds,
Paul

evertsen
1st November 2002, 04:06
If you are trying to update a table other than the main table this could cause your error. To confirm this, try this test... before you exit the session, hit the undo button and then exit. If you don't receive the error then you might have to use the after.update.db.commit section.

tools123
1st November 2002, 04:19
It is most likely an error based on the "other table".
The other table is the table on which the calling session is based
and the type of form used.
Check and change these and you should be ok.

ayoobi
1st November 2002, 07:57
Hi ,

I think the best way to solve your problem is to update the totals in after.update.db.commit section of the child .

Regards
Zubair