Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
I have a QlikView script which loads data from a stored procedure in Clarity and then saves the data in a .qvd file. Previously I was incrementally adding to this one, now very large, .qvd file on a daily basis. I have now decided to try to automatically create separate .qvd files for each month to make things easier if anything goes wrong with the reload process on the server at any time.
I have the following script, which works great so long as I already have a .qvd file for the current month. What I need to do is check that the file exists before trying to load it and if it doesn't then go straight to the part that runs the stored procedure.
Let vQVD = Date(MonthEnd(DayStart(now(),-1)),'MMMYYYY');
set Path = \\QlikView1\QVDocumentsE\Pharmacy\MCR Data\HCDs_$(vQVD);
HCDs:
LOAD *
FROM
$(Path).qvd
(qvd);
HCDs:
SQL exec CLARITY.dbo.SP_GO_DRUG_DISP_AND_ADMIN 'T-1', 'T-1';
Store HCDs into $(Path).qvd (qvd);
Drop Table HCDs;
So, does anyone know how to do an If...Then...Else kind of check for files in a QlikView Script?
Thanks,
Gethyn.
Thanks Stefan,
I just had to make a slight variation on your script to get it to work.
Let vQVD = Date(MonthEnd(DayStart(now(),-1)),'MMMYYYY');
set Path = \\QlikView1\QVDocumentsE\Pharmacy\MCR Data\HCDs_$(vQVD);
IF not isnull(QVDCreateTime('$(Path).qvd')) Then
HCDs:
LOAD *
FROM
$(Path).qvd
(qvd);
End If
HCDs:
SQL exec CLARITY.dbo.SP_GO_DRUG_DISP_AND_ADMIN 'T-1', 'T-1';
Store HCDs into $(Path).qvd (qvd);
Drop Table HCDs;
You can check for QVDCreateTime():
Let vQVDExists = not isnull(QVDCreateTime('$(Path)'));
IF vQVDExists THEN
HCD:
LOAD *
...
END IF
Thanks Stefan,
I just had to make a slight variation on your script to get it to work.
Let vQVD = Date(MonthEnd(DayStart(now(),-1)),'MMMYYYY');
set Path = \\QlikView1\QVDocumentsE\Pharmacy\MCR Data\HCDs_$(vQVD);
IF not isnull(QVDCreateTime('$(Path).qvd')) Then
HCDs:
LOAD *
FROM
$(Path).qvd
(qvd);
End If
HCDs:
SQL exec CLARITY.dbo.SP_GO_DRUG_DISP_AND_ADMIN 'T-1', 'T-1';
Store HCDs into $(Path).qvd (qvd);
Drop Table HCDs;