ben.kansas
9th January 2009, 23:17
Hi All,

I am attempting to update a table using data from a flat file via the DAL.

My code reads:


error.found = dal.change.object("tiedm110")

if error.found then
error.mess = "Could not do 'change object' for refdes line"
error.mess = dal.error.file
endif

dal.set.field("tiedm110.eitm", mitm)
dal.set.field("tiedm110.revi", revi)
dal.set.field("tiedm110.pono", pono)
dal.set.field("tiedm110.rdsp", rdsp)

error.found = dal.save.object("tiedm110")

if error.found then
while dal.get.first.error.message( msg, code) >= 0
message(msg)
endwhile
error.mess = "Could not save REFDES line"
error.mess = dal.error.file
else
commit.transaction()
endif


When the script try to execute the dal.save.object() function it throws the error that the record is not locked.

I would think that the dal.save.object() function would lock or delay lock the record prior to saving the object.

How can I lock the record so that the record can be modified and then committed to the database?

Thanks for your time,
Ben

ks_ks_
12th January 2009, 07:58
could you debug this and find out which line is the script throwing the error.

pconde
12th January 2009, 08:53
Hi,

If you are using dal to update a record you need first to read this record via
select tablename.*
from tablename for update
where ....

Regards
Philippe

NirajKakodkar
12th January 2009, 11:04
Hello Ben,

If you want to directly insert a new record , you can use the same code with a small change "dal.new.object("tiedm110")" and it will work ,
but here in this case you get a "record not locked error" , this is because while trying to update , the system do not find the record which you are trying to update so as Pconde suggested you will need to select the record for updating ....

Regards,
Niraj

ben.kansas
12th January 2009, 15:13
Thanks, Niraj, Philippe.

That solved my problem.

Thanks a million!

srkndnsn
12th January 2022, 09:43
Hi,

If you are using dal to update a record you need first to read this record via
select tablename.*
from tablename for update
where ....

Regards
Philippe

This advice make my day. Thanks a lot , totally appreciated.

Best regards
Serkan