olliwest
15th May 2008, 12:04
hello together,

i like to read my jobdata table (ttaad500) an set the content in different variables. But i get only the first row.

e.g. i have 4 Jobs in the table, but i get four times the first line.

function get.job.infos()
{
file.rm("jobinfos.txt")
path.id2 = "jobinfos.txt"
i=1

db.retry.point()
select count(ttaad500.cjob):number_jobs
from ttaad500
selectdo
endselect


if (number_jobs > 0) then
while(i <= number_jobs)
select ttaad500.cjob:jobname,ttaad500.desc:desc,ttaad500.user:user
from ttaad500
selectdo
endselect

seq.id2 = seq.open(path.id2,"a")
seq.write(str$(jobname),256,seq.id2)
seq.write(str$(desc),256,seq.id2)
seq.write(str$(user),256,seq.id2)

i=i+1
seq.close(seq.id2)
endwhile
endif


}


how can i read the table row by row?
can everbody help me

thanks olli

george7a
15th May 2008, 12:12
Hi,

Put your code inside the selectdo and it will be repeated for all the records that come out of the select. The code will look like this:

seq.id2 = seq.open(path.id2,"a")
select ttaad500.cjob:jobname,ttaad500.desc:desc,ttaad500.user:user
from ttaad500
selectdo
seq.write(str$(jobname),256,seq.id2)
seq.write(str$(desc),256,seq.id2)
seq.write(str$(user),256,seq.id2)

endselect
seq.close(seq.id2)

I hope it helps,

- George

olliwest
15th May 2008, 13:04
hi george7a,

thanks, it works fine

;-)