Quantcast
Channel: Baanboard.com
Viewing all articles
Browse latest Browse all 4216

db.retry.point

$
0
0
Hello,
I develop a table extension which updates field tsmsc110.csvl if field tsmsc120.pdis(1) has changed.

When testing and debugging the extension I sometimes get the error message which I attached. (DAL engine unreachable field. Transaction is on, cannot continue.)

I've read that this error message has to do with transaction handling and setting correctly the db.retry.point.

My code has a functions, before save and after save hook.
I use before save and after save to check if the value has changed.
If yes, than performe the dal.change in the after.save hook (function update.customs.value())
The db.retry.point is in the before save hook.
The commit/abort.transaction() is in the after save hook.

Is this correct?


This is my code:
Code:

|common functions to be used in extension script.

function get.old.values()
{
        old.disc = tsmsc120.pdis(1)
}

function long update.customs.value(domain tcitem item,
domain tcpono lino, domain tcorno orno, domain tcdisc disc)
{


long error.found
select  tsmsc110.*
from    tsmsc110 for update
where  tsmsc110.cmso = :orno and
        tsmsc110.item = :item and
        tsmsc110.lino = :lino
as set with 1 rows
selectdo
 error.found = dal.change.object("tsmsc110")
                if error.found then
                        dal.set.error.message("@Cannot update tsmsc110 for item %1$s.", item)
                        return(DALHOOKERROR)
                else
                        dal.set.field("tsmsc110.csvl", tsmsc110.pris*(1-disc/100))
                       
                       
                        error.found = dal.save.object("tsmsc110")
                        if error.found then
                                dal.set.error.message("@Cannot save tsmsc110 for item %1$s.", item)
                                return(DALHOOKERROR)
                        endif
                endif
endselect

return (0)
}

|function for return value and end of transaction handling
function void handle.return.value(long retval)
{
on case retval

case 0:
        commit.transaction()
        break

case DALHOOKERROR:
        abort.transaction()
        show.dal.messages()
        break

default:
        abort.transaction()     
        show.dal.messages()
        break

endcase
}


| before save
function extern long before.save.object(long mode)
{
        db.retry.point()
        on case mode
        case DAL_NEW:
                break
        case DAL_UPDATE:
                with.old.object.values.do(get.old.values)
                break
        endcase
        return(0)
}

| after save
function extern long after.save.object(long mode)
{
        long ret
        on case mode
        case DAL_NEW:
                break
        case DAL_UPDATE:
                | discount has been changed --> update customs value
                if double.cmp(tsmsc120.pdis(1), old.disc, 0.001) then
               
                        ret = update.customs.value(tsmsc120.item, tsmsc120.lino, tsmsc120.cmso, tsmsc120.pdis(1))
                        handle.return.value(ret)
                endif       
                break
        endcase
        return(0)
}


Attached Images
File Type: png error.png (62.0 KB)

Viewing all articles
Browse latest Browse all 4216

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>