Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have something I believed is very simple; I am trying to load a number of tables (50+) and do field mapping for them and then save them into appropriate qvd files for further processing
I have used and modified code found here:
For loading maps:
For each vFileName in Filelist ('C:\Users\xxxxxxxxxxxxxx\*_opis.txt');
let vFileName1 = SubField(SubField('$(vFileName)', '\', 9), '_', 1) & '_map';
let vFileName2 = SubField(SubField('$(vFileName)', '\', 9), '_', 1);
qualify *;
$(vFileName1):
mapping
Load
'$(vFileName2).@' & text( RecNo()) as @1,
@1 as @2
From [$(vFileName)] (txt, codepage is 1250, no labels, delimiter is ':', msq);
Next vFileName
For loading data:
For each sFileName in Filelist ('C:\Users\xxxxxxxxxxxxxxxxxxxxxx\*_unl.txt')
let sFileName1 = SubField(SubField('$(sFileName)', '\', 9), '_', 1);
let sFileName2 = sFileName1 & '_map';
$(sFileName1):
Load *
From [$(sFileName)] (txt, codepage is 1250, no labels, delimiter is ':', msq);
RENAME Fields using $(sFileName2);
Next sFileName
The interesting thing is this: when I do reload, all maps are loaded correctly and data is loaded correctly BUT mapping is loaded correctly only for some fields and not for all.
I am confused why is this happening since field map is generated on the fly while loading and should be exactly the same.
Now, some fields in my databases overlap (keys) and I figured out that when one of my imports use field map for the first time then it is ok, but all subsequent occurances of the same field name will result in a failed field map.
If I name all fields to be unique (simulate qualify statement in field names) then import works out ok. This is the code I added to my mapping load (instead of the line I wrote above):
'$(vFileName2).@' & @1 as @2 |
My question is following: is this normal behaviour or I have stumbled upon a bug?
Hi
I see you have a qualify statement for the map loading, and not for the data load. I see that your logic needs the qualify on the data load, and not on the mapping load.
Also, you cannot map rename the fields into fieldnames that already exist, so doing the rename in the loop may be a problem (if the target field name was remapped on the last pass, the next rename to that target will fail) . Have you tried doing the remapping after the loop?
HTH
Jonathan
when I added my "simulation" of qualify for field names from that point on everything worked
it is just interesting that I have hit this limitation of rename fields function which was not obvious, so this post was more as a written word that somewhere, someone had that problem before and how it was solved .)