ltannous
5th May 2005, 20:20
I have a field tdpur003.iedi that is an array of 5. In my db.update script
how can I say that tdpur003.iedi(1) = orders?

This is what I have

var = timrp943.dtwk
var1 = timrp943.dtwk + 6

select sum(timrp010.qana):orders
from timrp010
where timrp010.item = :timrp943.item
and timrp010.kotr = tckotr.requirement
and timrp010.date inrange :var and :var1
selectdo
selectempty
orders = timrp010.qana

select tdpsc003.iedi
from tdpsc003 for update
where tdpsc003.suno = :timrp943.suno
and tdpsc003.cont = :timrp943.cont
and tdpsc003.pono = :timrp943.pono
and tdpsc003.item = :timrp943.item
and tdpsc003.dtwk inrange :var and :var1
selectdo
count = count + 1
if count > 50 then
count = 0
endif
selectempty
tdpsc003.iedi(1,5) = orders
db.insert(ttdpsc003)
commit.transaction()
endselect
endselect

Youp2001
10th May 2005, 10:04
What exactly is your problem. Does the code you posted not work?

Normally the way to fill an array element is by just adding something like:

tdpsc003.iedi(1) = orders | Set the first element in the array
tdpsc003.iedi(2) = orders | Set the second element in the array
etc.

Your code contains the line:
tdpsc003.iedi(1,5) = orders
The application assumes now that this field is a two dimensional array (which is not possible on a table field).

Success.

Youp

kathuria
10th May 2005, 11:30
Hi,

It's depend upon data type of depth field. if it's string in that case u will use two dimensional arrar and in case of double or integer u will use one dimensional array.

e.g.

String :
tdpsc003.iedi(1,1) = orders1
tdpsc003.iedi(1,2) = orders2
tdpsc003.iedi(1,3) = orders3
tdpsc003.iedi(1,4) = orders4

Integer/Double:
tdpsc003.iedi(1) = orders1
tdpsc003.iedi(2) = orders2
tdpsc003.iedi(3) = orders3
tdpsc003.iedi(4) = orders4

RobertB
10th May 2005, 13:12
I've always used a buffer array which I set up independently of the table/table fields and then simply assign this buffer "value" to the array field.
Here's a code fragment from an old script:|******************************************************************************
function write.to.other.parts.report.table(long i.period)
{
domain tcitem this.item
domain tcemno item.plid
domain tcqiv1 item.bqan, a.new.rec(14), a.buffer(14)


| For all in Temp BOM table.......
select titad988.item:this.item, titad988.bqan:item.bqan, titad988.plid:item.plid
from titad988
order by titad988._index1
selectdo

| ... Update Other Parts table....
db.retry.point()
select titad987.*
from titad987 for update
where titad987._index1 = {:this.item}
selectdo
a.buffer = titad987.cnsm | This is an array field...
a.buffer(i.period) = a.buffer(i.period) + item.bqan | Update buffer...
put.var(pid, "titad987.cnsm", a.buffer) | Update array field with buffer...
| titad987.cnsm(i.period) = titad987.cnsm(i.period) + item.bqan | Doesn't work...
db.update(ttitad987, DB.RETRY)
selectempty

set.mem(a.new.rec, 0.0, 14) | Create new buffer...
a.new.rec(i.period) = item.bqan | Update new buffer....

titad987.item = this.item
titad987.plid = item.plid
titad987.cnsm = a.new.rec | Write new buffer to field...
db.insert(ttitad987, DB.RETRY)
endselect
commit.transaction()

selectempty

endselect

} Hope this helps.
Robert

ltannous
11th May 2005, 00:09
Hi,

It's depend upon data type of depth field. if it's string in that case u will use two dimensional arrar and in case of double or integer u will use one dimensional array.

e.g.

String :
tdpsc003.iedi(1,1) = orders1
tdpsc003.iedi(1,2) = orders2
tdpsc003.iedi(1,3) = orders3
tdpsc003.iedi(1,4) = orders4

Integer/Double:
tdpsc003.iedi(1) = orders1
tdpsc003.iedi(2) = orders2
tdpsc003.iedi(3) = orders3
tdpsc003.iedi(4) = orders4

My field is a string. I used the tdpsc003.iedi(1,1), but noting is being inserted. I even tested this with tdpsc003.iedi(1,1) = "test", but no luck.

csecgn
11th May 2005, 10:30
Hi Itannous,

just some things I've seen:

you are trying to insert during selectempty in your example:
I'm missing all fields i.e. needed for the primary key
You are trying to fill a string with a double (qana)?

Regards
csecgn

ltannous
11th May 2005, 22:57
It is still not updating the field
Also how can I write a double to a string

function read.main.table()
{
long count
db.retry.point()
orders = 0
timrp010.qana = 0
var = timrp943.dtwk
var1 = timrp943.dtwk + 6

select timrp943.*, timrp942.*, tccom020.*, tiitm001.*
from timrp943, timrp942, tccom020, tiitm001
where timrp943._index2 inrange {:suno.f, :item.f, :cont.f,
:pono.f, :year.f, :week.f, :orno.f}
and {:suno.t, :item.t, :cont.t, :pono.t, :year.t,
:week.t, :orno.t}
and timrp943.orno refers to timrp942
and timrp943.suno refers to tccom020
and timrp943.item refers to tiitm001
order by timrp943._index2

selectdo

select sum(timrp010.qana):orders
from timrp010
where timrp010.item = :timrp943.item
and timrp010.kotr = tckotr.requirement
and timrp010.date inrange :var and :var1
selectdo
orders = timrp010.qana

select tdpsc003.*
from tdpsc003 for update
where tdpsc003.suno = :timrp943.suno
and tdpsc003.item = :timrp943.item
and tdpsc003.cont = :timrp943.cont
and tdpsc003.pono = :timrp943.pono
and tdpsc003.dtwk inrange :var and :var1
selectdo
count = count + 1
if count > 50 then
count = 0
endif
tdpsc003.iedi(1,1) = "test"|orders
db.insert(ttdpsc003, db.retry)
commit.transaction()

rprt_send()

endselect
endselect
endselect
}

ltannous
12th May 2005, 00:00
I made some changes, but did this in my report script and it works now.