Focal Point
[CLOSED] read 10 rows at a time from the loop and add it to end result and loop again

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6037037196

September 27, 2019, 03:03 PM
v_ani
[CLOSED] read 10 rows at a time from the loop and add it to end result and loop again
Hi,
I need to read 10 rows at a time and add the result to end result and loop again another next 10 rows and add it end result until finshis all the rows in the table .I appreacite if any one have suggestion about this issue.
 
TABLE FILE TESTFILE
BY TESTFIELD
WHERE READLIMIT EQ 1000
ON TABLE HOLD AS MASLIST
END
-*=======================================

-SET &LOOPCNT=&LINES;

-SET &I=1;
-REPEAT ENDREPEAT WHILE &I LT &LOOPCNT;
-TYPE I &I


TABLE FILE MAS_LIST
PRINT
         FILENAME_UPPER
WHERE    (ROW_NUM EQ &I.EVAL)
ON TABLE SAVE    AS MASITEM
END
-RUN

-SET  &HLD_FIL_NAME = IF (&I.EVAL) GT 1  THEN 'FINALLST' ELSE 'FEXCOUNT&I.EVAL';

DEFINE FILE FEXDETAILS
   MASFILE/A50='&MSTRNAME';
END
TABLE FILE FEXDETAILS
BY FEX_NAME  AS 'FEXCOUNT'
BY MASFILE
WHERE CODE_LINE CONTAINS  '&MSTRNAME'
ON TABLE HOLD     AS &HLD_FIL_NAME
END
-RUN


-IF &HLD_FIL_NAME EQ 'FINALLST' GOTO SKP_MORE;


TABLE FILE FINALLST
BY  FEXCOUNT
BY  MASFILE
ON TABLE HOLD AS FINALLST
MORE
FILE FEXCOUNT&I.EVAL
END

-SKP_MORE


-SET &I=&I+1;

-ENDREPEAT1

TABLE FILE FINALLST
PRINT *
ON TABLE PCHOLD FORMAT HTML
END








 

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8
Windows, All Outputs
September 27, 2019, 03:45 PM
MartinY
Your code does not make sense for me (at least partially).

You are doing TABLE FILE MAS_LIST to SAVE to a file that is not used

How does ROW_NUM is defined ? With this code you will SAVE AS MASITEM as many time you loop and this for nothing

You filter WHERE CODE_LINE CONTAINS '&MSTRNAME' where &MSTRNAME is not defined anywhere

You have no where something that can limit to 10
You may need a loop in a loop


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
September 27, 2019, 04:02 PM
BabakNYC
I'm at a loss how this is a spec for a BI platform. Could you share the use case for this?


WebFOCUS 8206, Unix, Windows
September 27, 2019, 04:06 PM
v_ani
Sorry for Mistype. Right now i am reading 1 row but my request is read 10 row at a time instead of 1 row.

   TABLE FILE TESTFILE
PRINT
COMPUTE ROW_NUM/I3 = ROW_NUM + 1;
BY TESTFIELD
WHERE READLIMIT EQ 1000
ON TABLE HOLD AS MAS_LIST
END
-RUN



WebFOCUS 8
Windows, All Outputs
September 27, 2019, 07:14 PM
Crymsyn
By reading 10 rows at a time are you meaning instead of having just one row per loop when doing
 WHERE (ROW_NUM EQ &I.EVAL)
ON TABLE SAVE    AS MASITEM

You would want 10 rows at a time?

If that is the case can instead of using ROW_NUM can divide ROW_NUM by ten and use that to limit instead. so something like this
COMPUTE ROW_NUM_GROUP/I3 = (ROW_NUM-1)/10;

Would ignore the remainder and only have 0 - 99. (The -1 is so that the first group will have ten instead of nine values)
That way the save file would have ten rows instead of one in each iteration of the loop if you change there WHERE to look at that group compute instead.
WHERE (ROW_NUM_GROUP EQ &I.EVAL)

Forgot to also mention will need to divide how you get the value for &LOOPCNT by 10 as well or will loop too many times.

If is more getting ten values onto one line to be able to use a -READ to read all ten at once would need an additional field as above that would use the MOD function and do an across value to put it into something like FILENAME_UPPER1, FILENAME_UPPER2, FILENAME_UPPER3, etc. If only working with hold/save files or that isn't what you would be wanting can ignore using the MOD function.


WF: 8201, OS: Windows, Output: HTML, PDF, Excel
September 29, 2019, 11:01 AM
Doug
Would you please explain your expected results...
It sounds like you'll get all the rows in the table anyway. Are you expecting to see only Ten Rows on the screen at a time? If so, consider LINES-PER-PAGE / Pagination (Basic WebFOCUS functionality)
quote:
and add it end result until finshis all the rows in the table





   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206