Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How could I capture the maximum value of a field into a variable in order to use it into a loop
Something like this:
set lastrow=max(RowID);
for n=1 to lastrow
...
Thanks
you need to make a teporary table for this:
temp: Load Max(RowID) as max_RowId resident table;
Then you can give this value in your variable with Peek():
let lastrow = Peek('max_RowId',-1);
you need to make a teporary table for this:
temp: Load Max(RowID) as max_RowId resident table;
Then you can give this value in your variable with Peek():
let lastrow = Peek('max_RowId',-1);
If you want to loop on the rows of Table1 and get for every row the value of Field1
Table1:
LOAD * INLINE [
Field1
1
2
3
10
4
5
];
FOR r=0 TO NoOfRows('Table1')-1
LET vField1 = PEEK('Field1', $(r), 'Table1');
TRACE $(r) $(vField1);
NEXT
IF you want to get the max value of Field1 and loop from 1 to max value of Field1
Table1:
LOAD * INLINE [
Field1
1
2
3
10
4
5
];
TMP:
LOAD MAX(Field1) AS Field1Max RESIDENT Table1;
LET vMax = Peek('Field1Max');
FOR i=1 TO $(vMax)
TRACE $(i);
NEXT
Thank for your usefull and quikly help.