Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jjordaan
Partner - Specialist
Partner - Specialist

Check existence field in QVD while loading QVD in QVW

Hello everyone,

I have created multiple QVD's with 1 QVD creator made ​​from 2 databases. The names of QVD that were created are equal.
However some of the field names in the QVD are not equal.
For example QVD name location (1) is a field named [Country_Region Code] while in the QVDnaam location (2) the field is called [Country Code].

Can I check the existence of a field while loading the QVD into a QVW?
If I can, can I also rename the field [Country_Region Code] to the name and Location Country and also for the field [Country Code]? thank you so much for the help.

1 Solution

Accepted Solutions
Anonymous
Not applicable

Use ErrorMode, something like this:

SET ErrorMode=0;

LOAD "Country_Region Code" from <your qvd>;

IF ScriptError =11 then
LOAD
...
"Conutry Code"
...
FROM ...
else
LOAD
...
"Country_Region Code" as "Country Code"
...
FROM ...
endif

SET ErrorMode=1;

View solution in original post

7 Replies
Not applicable

Hi Jeroen,

don't know how to check for existing fieldnames during a load command. But try to use a mapping table to rename the fieldnames:

FieldMap:

Mapping

LOAD * Inline [

OldName, NewName

Country_Region Code, Country Code

];

After every LOAD from a qvd-file (or whatever):

RENAME Fields using FieldMap;

Regards Roland

Not applicable

Hi Jordan,

If only one field is different name, Just pass the variable for that field.

We can find the QVD Filed name by function: QvdFieldName(filename , fieldno) and QvdNoOfFields(filename)

EX:  QvdFieldName ('MyFile.qvd', 3)

We can use the for loop and retive all the fields from alrady stored QVD.

Hope this will help you.

Thanks & Regards,

Siri

Anonymous
Not applicable

Use ErrorMode, something like this:

SET ErrorMode=0;

LOAD "Country_Region Code" from <your qvd>;

IF ScriptError =11 then
LOAD
...
"Conutry Code"
...
FROM ...
else
LOAD
...
"Country_Region Code" as "Country Code"
...
FROM ...
endif

SET ErrorMode=1;

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You can read the QVD meta data (providing the QVD was saved with V10 SR1 or greater):


LOAD FieldName,

    FileName() As Source

FROM *.qvd (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);

This can form the basis of a flexible read method.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jjordaan
Partner - Specialist
Partner - Specialist
Author

Jonathan,

Thanks for the answer.
Maybe this is a very stupid question but how can I use the metadata for a flexible read?

Can I perform IF(Exists) on the metadata table when I'm loading a QVD into a QVW?

jjordaan
Partner - Specialist
Partner - Specialist
Author

Hi Roland,


By your response to my post, I have made a mapping table with renaming fields.
The problem, however, I walk against it is that during running the script announces that the [Country_region code] not exists in the QVD.

For these reasons I can not make the translation.

I can use this method for something else.

Thanks again

Not applicable

Hi Jeroen,

thanks for your answer. The idea of the mapping table was: if field(s) exists, it (they) will be renamed. If not,nothing will happen, especially no error should occure. So it should be very flexible.

Anyway:

Jonathan and Michaels posts should bring you forward, and I learned new things about qvd meta data.

RR