Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'd like to load the same table several times, each time giving a different name to it's fields.
Say that I have a "NAME" field on the table. Then I want to load it once as NAME1 then NAME2 and so forth up to NAME10.
Looks easy but it does not work !
Attached sample is pretty straightforward to check the problem !
Any hints or suggestions ?
Thanks in advance !
I figured it out.
it was a problem with the resident table Map_Fields
This did the trick:
FOR NRO=1 TO 5
MAP_FIELDS$(NRO):
MAPPING LOAD * INLINE [
NAME_FROM,NAME_TO
SIGLUF_VSUFS,SIGLUF_VSUFS$(NRO)
NOMEUF_VSUFS,NOMEUF_VSUFS$(NRO)
];
VSUFS$(NRO):
LOAD
*
FROM TEST165P.CSV (OEM, TXT, DELIMITER IS ';', EMBEDDED LABELS, NO QUOTES);
RENAME FIELDS USING MAP_FIELDS$(NRO);
NEXT
Adriano,
not sure if you were looking for this:
FOR NRO = 1 TO 5
VSUFS$(NRO):
LOAD SIGLUF_VSUFS as SIGLUF_VSUFS$(NRO),
NOMEUF_VSUFS as NOMEUF_VSUFS$(NRO)
FROM [TEST165P.CSV] (ansi, txt, delimiter is ';', embedded labels, msq);
NEXT
Let me know if it works.
Moreover,
if you want them in the same table:
you can use concatenate(VSUFS)
as opposed to storing into a new resident table.
It could work. But I'm intrigued why my original MAP approach does not work.
As for concatenating, not a good idea.
This table above is for STATES or PROVINCES.
Say that I have a CLIENT table with three STATEs fields :
So, we have three foreign keys pointing to the same table (STATEs). I prefered to clone this table. Thus the need to replicate it's load in three different tables...
In the earlier scenario, you were trying to rename all fields to <fieldname> followed by 1
instead of <fieldname> followed by $(NRO)
I would assume that to be the reason.
I posted wrong the ZIP file. Get it again and you'll see it fixed...
I figured it out.
it was a problem with the resident table Map_Fields
This did the trick:
FOR NRO=1 TO 5
MAP_FIELDS$(NRO):
MAPPING LOAD * INLINE [
NAME_FROM,NAME_TO
SIGLUF_VSUFS,SIGLUF_VSUFS$(NRO)
NOMEUF_VSUFS,NOMEUF_VSUFS$(NRO)
];
VSUFS$(NRO):
LOAD
*
FROM TEST165P.CSV (OEM, TXT, DELIMITER IS ';', EMBEDDED LABELS, NO QUOTES);
RENAME FIELDS USING MAP_FIELDS$(NRO);
NEXT