Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
mohan2391
Contributor II

Reload should fail if QVD size is zero

Hi,

 

I have a requirement where the reload of QVW should stop when the size of QVD which I am loading in the QVW is zero.

How to achieve this ?

 

Thanks in advance

 

3 Solutions

Accepted Solutions
vvvvvvizard
Contributor III

Re: Reload should fail if QVD size is zero

if QvdNoOfRecords('Qvd name')<=0
EXIT SCRIPT
ELSEIF store qvd into path.qvd(qvd);
ENDIF

shiveshsingh
Honored Contributor

Re: Reload should fail if QVD size is zero

Before loading statement, you need to put below condition to check..

IF (qvdNoOfRecords('$(Path)') <= 0) THEN 

Re: Reload should fail if QVD size is zero

If you want a task furter up in the QMC chain to not run when a QVD is found to be empty, let your script crash if you detect no loaded rows. I often use a self-invented statement called CRASH; to do this Smiley Wink, because QlikView doesn't supply something similar. Your script then becomes

TableSomething:
LOAD * FROM SomeFile (SomeOptions);

IF NoOfRows('TableSomething') = 0 THEN
  CRASH;
END IF

Of course, the task will fail and you will get an appropriate email scream from the QDS. But the second task will not run.

 

17 Replies
vvvvvvizard
Contributor III

Re: Reload should fail if QVD size is zero

if QvdNoOfRecords('Qvd name')<=0
EXIT SCRIPT
ELSEIF store qvd into path.qvd(qvd);
ENDIF

shiveshsingh
Honored Contributor

Re: Reload should fail if QVD size is zero

Before loading statement, you need to put below condition to check..

IF (qvdNoOfRecords('$(Path)') <= 0) THEN 

Re: Reload should fail if QVD size is zero

As a second method, you can leave the LOAD logcic unchanged and add a test after the LOAD statement has been executed. Although the overhead of loading the XML header twice is not that large, you skip at least one of them. E.g.

 

TableSomething:
LOAD * FROM SomeFile (SomeOptions);

IF NoOfRows('TableSomething') = 0 THEN
  EXIT SCRIPT;
END IF

 

 

mohan2391
Contributor II

Re: Reload should fail if QVD size is zero

Hi,

 

Thanks for your quick reply.

I forgot to mention 1 point, so please let me know if this code satisfies that or no.

Missed Point: I have 2nd QVW which runs after successful run of 1st QVW(here in 1st qvw, we are writing that above code) one.

So my requirement is that the 2nd QVW also should not run if the QVD size is zero along with the failure of 1st QVW.

 

So the code which you suggested can work for my other requirement as well ?

mohan2391
Contributor II

Re: Reload should fail if QVD size is zero

Thanks for your reply, same question to you as well.

 

I forgot to mention 1 point, so please let me know if this code satisfies that or no.

Missed Point: I have 2nd QVW which runs after successful run of 1st QVW(here in 1st qvw, we are writing that above code) one.

So my requirement is that the 2nd QVW also should not run if the QVD size is zero along with the failure of 1st QVW.

 

So the code which you suggested can work for my other requirement as well ?

shiveshsingh
Honored Contributor

Re: Reload should fail if QVD size is zero

If your code will exit after checking first qvd then it'll not go to script further.

 

 

mohan2391
Contributor II

Re: Reload should fail if QVD size is zero

it will not go to the further script in the SAME qvw (that means in 1st QVW)

But my question is, I have 2 QVWs. In QMC, there are 2 tasks created on these and there is task dependency created between them so that 2nd QVW will start run once 1st qvw runs successfully.

 

In the 1st QVW, I want to check QVD size is zero or not. If it is zero it should stop immediately AS WELL AS it SHOULD NOT allow 2nd QVW to run. So the 2nd QVW will run or no if I use your code and the QVD size is zero ?

Partner
Partner

Re: Reload should fail if QVD size is zero

 

DataFromQvd1:
Load 
  * 
from Qvw1;
//If you have publisher, use variable below in QMC
Let vNoOfRecords =NoOfRecords() ;

Store DataFromQvd1 into DataFromQvd1.qvd (qvd);

//running second Qvw conditionally
Let NoOfQvd1Records= QvdNoOfRecords(DataFromQvd1);

If $(NoOfQvd1Records) >0 then
     //Run Second Qvw
     DataFromQvd2: 
     Load * from Qvw2;
     Store DataFromQvd2 into DataFromQvd2.qvd (qvd);
Else
    //Exit Script               
Endif
mohan2391
Contributor II

Re: Reload should fail if QVD size is zero

I am using binary load of 1st qvw in 2nd qvw