Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Folks,
Thanks in advance.
How I create a loop to check whether I'm getting right table structure or not?
In one folder on server 'E:\Data\..' i get 3 excel file which moved in 'D:\Data\..' by batch files. from 'D:\Data\..' Qlikview starts to fetch data.
but before moving in 'D:\Data\ i want check the structure of files. so how can i write script to check structure?
Emp:
key | emp_id | emp_name |
---|---|---|
1 | EMP1 | A |
2 | EMP2 | B |
3 | EMP3 | c |
Source:
key | date | source | location |
---|---|---|---|
1 | 22/4/2016 | postgres | Uk |
2 | 15/7/2016 | teradata | Us |
3 | 12/3/2015 | oracle | Sng |
Period:
Year | Month | day | Mng_id | key |
---|---|---|---|---|
2016 | jan | 3 | 567 | 1 |
2017 | dec | 4 | 345 | 2 |
2017 | feb | 5 | 234 | 3 |
You can read the XML metadata of the QVD file to check field existance such as this example
QvdFieldHeader:
LOAD FieldName
FROM F:\YOURPATH\Emp.qvd (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);
For i = 0 to NoOfRows('QvdFieldHeader')-1
LET vFieldName = peek('FieldName', $(i));
if FieldIndex('FieldName',peek('FieldName', $(i))) > 0 then
Trace 'Field ' & '$(vFieldName)' & ' exists';
LET vStructureOK = true();
else
Trace 'Field ' & '$(vFieldName)' & ' is missing';
LET vStructureOK = false();
end if;
next
if $(vStructureOK) = true() Then
//Load from QVD
ELSE
//....
END IF
//cleanup
LET vFieldName =;
LET vStructureOK =;
EXIT Script;