Focal Point
how to store all the selected rows through a SQLin a table and retrieve the data back

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

December 04, 2004, 01:05 PM
<gaurav>
how to store all the selected rows through a SQLin a table and retrieve the data back
Hi,
I have to store start date and end date of each week. I started a loop with counter starting from first week to the last week to retrieve each week's start and end date and store it in a table.
But the table stores only the last week's data.
The code for the same is as below:

-REPEAT TEST FOR &TEMPWEEK FROM &STARTWEEK TO &ENDWEEK

SQL
SELECT WK_BEG_D, WK_END_D FROM ACCT_DATE WHERE WK_COUNT_I = &TEMPWEEK;
TABLE
ON TABLE HOLD AS WEEK_DETAILS
END
-TEST


Can some one help me out in the above problem.
Also once I store all the data in a hold, how would I retieve each row's data from that hold to be used further.

TIA
Gaurav
December 05, 2004, 02:22 AM
TexasStingray
That's Correct it would only store that last instance of data as each loop recreates that hold file. Try a filedef for the hold file with append before the loop and besure to issue a -RUN after the FILEDEF.

Example:
FILEDEF WEEK_DETAILS DISK C:\IBI\APPS\basedir\WEEK_DETAILS.FTM (APPEND
-RUN

you might have to use hold format ALPHA:

example:
ON TABLE HOLD AS WEEK_DETAILS FORMAT ALPHA
December 06, 2004, 12:43 AM
Piipster
If you want all the weeks in one file, can you select all the weeks at one time, rather than doing one pass for each value of your counter?

ie select rows where WK_COUNT_I from &STARTWEEK to &ENDWEEK

(Sorry, don't write SQL often, but I would guess that is doable.)

Then you don't have to worry about the append.