ltannous
10th October 2002, 22:52
I am writing an update script for a session that will update the sales price in the sales contracts with the standard cost price from item data.
This seems to work when I select only one item at a time.
How can I update a range of items when I select a range of items.
This is what I have so far:


functions:
function read.main.table()
{
long count
db.retry.point()

select tdssc001.*
from tdssc001 for update
where tdssc001._index3 inrange {:item.f, :cuno.f, :cdel.f , :cont.f, :pono.f}
and {:item.t, :cuno.t, :cdel.t,:pono.t}
order by tdssc001._index3
selectdo
refresh()
select tiitm001.copr
from tiitm001
where tiitm001.item inrange :item.f and :item.t
selectdo
itmpric = tiitm001.copr
|update set
tdssc001.pric = itmpric
db.update(ttdsc001, db.retry)
count = count + 1
if count > 50 then
count = 0
commit.transaction()
endif
endselect
endselect
commit.transaction
refresh()
}



:mad:

benito
10th October 2002, 23:14
db.retry.point()
select tdssc001.*
from tdssc001 for update
where tdssc001._index3 inrange {:item.f, :cuno.f, :cdel.f , :cont.f, ono.f}
and {:item.t, :cuno.t, :cdel.t,ono.t}
order by tdssc001._index3
selectdo
tdssc001.pric = itmpric
db.update(ttdsc001, db.retry)
endselect
commit.transaction()
}

~Vamsi
10th October 2002, 23:22
The previous solution is missing the select on the Item Master. See if the below code works with the Item Master added in:functions:
function read.main.table()
{
long count
db.retry.point()

select tdssc001.*, tiitm001.copr
from tdssc001 for update, tiitm001
where tdssc001._index3 inrange {:item.f, :cuno.f, :cdel.f , :cont.f, :pono.f}
and {:item.t, :cuno.t, :cdel.t,:pono.t}
and tdssc001.item refers to tiitm001
order by tdssc001._index3
selectdo
|update set
tdssc001.pric = tiitm001.copr
db.update(ttdssc001, db.retry)
count = count + 1
if count > 50 then
count = 0
commit.transaction()
endif
endselect
commit.transaction
}

ltannous
10th October 2002, 23:47
Thanks for your help. It works great.