Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I need some help with this scenario.
I have let say 3 QVDs .
qvdtable1
TYPE DATE qvdtable1_ID
qvdtable2
TYPE DATE qvdtable2_ID
qvdtable3
TYPE DATE qvdtable3_ID
I am trying to load all the QVDs in one script but dynamically rename the qvdtable*_ID To ID.
How could this be achieved?
Thanks
Sounds like you want the FileName() function... This will return the full name of the file including .qvd extension. If the only number in the name is what you want to keep, simply use KeepChar() to purge everything but numbers from the name. Example below.
Load
qvdtable$(KeepChar(FileName(),'0123456789')).ID as ID,
Type,
Date
From qvdtable*.qvd (qvd);
Alternatively you could loop through the tables.
For Each vIteration In FileList('FileLocation\qvdtable*.qvd')
Load
qvdtable$(vIteration).ID as ID,
Type,
Date
next vIteration;
However you might have some issues if you don't have a sequential list of numbers.
Thanks,
Sam
Hi Didier,
Use Qualify for dynamic renaming your fileds just Give tablename like Qvd1
Then Field name will display like Qvd1.ID
Thanks,
Arvind Patil
Sounds like you want the FileName() function... This will return the full name of the file including .qvd extension. If the only number in the name is what you want to keep, simply use KeepChar() to purge everything but numbers from the name. Example below.
Load
qvdtable$(KeepChar(FileName(),'0123456789')).ID as ID,
Type,
Date
From qvdtable*.qvd (qvd);
Alternatively you could loop through the tables.
For Each vIteration In FileList('FileLocation\qvdtable*.qvd')
Load
qvdtable$(vIteration).ID as ID,
Type,
Date
next vIteration;
However you might have some issues if you don't have a sequential list of numbers.
Thanks,
Sam
Hi Didier,
I think Sam has given you excellent advice that looks like the correct answer to me. I just want to say that if you try another method like renaming after loading the tables you will have problems because QV won't allow you to change a field name to one that already exists in a resident table. If you know that already then apologies, I only mention it because I remember when I had an issue with that until I realised I was trying to do something QV wouldn't allow.
Cheers
Andrew