Focal Point
Variables from a data source

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

April 11, 2006, 02:15 AM
Karanth
Variables from a data source
I need to take some data from a table for example:
TABLE FILE CAR
PRINT
COUNTRY
on table save as ...
END

For each country then i need to get data from a table. I need to write a query for each table.
So how do i store Country as an &field.
How do i read the saved file and navigate record by record?

I AM DOING SOMETHING LIKE THIS:
-* File readfile.fex
FILEDEF PASS DISK C:
-RUN

TABLE FILE EMPDATA
PRINT
DIV
ON TABLE SAVE AS PASS
END
-RUN
-TYPE &LINES

-REPEAT LAB1 &LINES TIMES
-TYPE INSIDE
-READ PASS &DIV.A4.
-RUN
-TYPE &DIV
-LAB1
-TYPE OUTSIDE

but for the number of records i get only the first DIV printed . so bsically CORP gets printed 41 times...how do i move to the next record in the file?

This message has been edited. Last edited by: Karanth,
April 11, 2006, 04:48 AM
<Special-K>
You should be using BY not PRINT, e.g. if EMPDATA is

DIV

AAA ...
AAA ...
BBB ...
BBB ...
CCC ...
CCC ...

you'll get six records output via PRINT and DIV will repeat as above, use BY and you'll get

AAA ...
BBB ...
CCC ...
April 11, 2006, 08:31 AM
ruhan
Remove the -RUN and try again. Normally -RUN closes files...
April 11, 2006, 09:10 AM
TexasStingray
HERE is an easier way

TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY EQ 'ENGLAND'
ON TABLE SAVE AS TMP1 FORMAT ALPHA
END

TABLE FILE CAR
PRINT COUNTRY CAR MODEL RETAIL_COST
WHERE COUNTRY IN FILE TMP1
END




Scott

use the NOCLOSE command
-READ MYFILE NOCLOSE &MYVAR.A8
NOCLOSE allows the file to stay open and go on to the next record when you loop back to the -READ statement.
works for -WRITE as well.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Thanks for your messages. I removed the RUN and it worked.