ltannous
14th October 2002, 04:49
I am trying to write an update session that selects the standard cost of an item from comapany A, and updates the purchase price in item data in company B. for a range of items.

This is what I have so far:

functions:

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

select tiitm001.*
from tiitm001
where tiitm001._compnr = "A"
selectdo

tiitm001.item = itmA
tiitm001.copr = coprA

select tiitm001.*
from tiitm001
where tiitm001._index1 in range {:item.f}
and {:item.t}
and tiitm001._compnr = "B"
order by tiitm001._index1
selectdo
|update set

if tiitm001.item = itmA
then
tiitm001.prip = coprA
db.update(ttiitm001, db.retry)
count = count +1
if count > 50 then
count = 0
commit.transaction()
endif
endif
endselect
commit.transaction()

}

evertsen
14th October 2002, 09:21
I think it might work better as below...

function read.main.table()
{
db.retry.point()

select tiitm001.*
from tiitm001
where tiitm001._compnr = "A"
selectdo

itmA = tiitm001.item
coprA = tiitm001.copr

select tiitm001.*
from tiitm001 for update
where tiitm001._index1 = {:itmA}
and tiitm001._compnr = "B"
selectdo
tiitm001.prip = coprA
tiitm001._compnr = "B"
db.update(ttiitm001, db.retry)
commit.transaction()
endselect
endselect
}

ltannous
15th October 2002, 04:30
Thanks Evertsen - It worked GREAT!