Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional reload

Hi,

This is the case. I need to do conditional reload. I have a table with last source database update date. This is one row table. i need the script to compare two dates - todays date and last database update date. If todays date =last update date i want the script to reload data, if not I want to exit script and save the appliaction with old data.

Any ideas?

1 Solution

Accepted Solutions
sparur
Specialist II
Specialist II

Of course, you can.

View solution in original post

10 Replies
sparur
Specialist II
Specialist II

Hello.

If I understand, you need such as:

tmpLastUpdateDate:

LOAD [Last Update Date]; SQL SELECT "Last Update Date" FROM SystemTable;

LET vLastUpdDate = peek('Last Update Date', 0);

IF $(vLastUpdDate = Today(1) THEN

//load your data from DB

LOAD ... FROM...

ELSE

exit script;

END IF;

Not applicable
Author

Thanks. It seems to be good idea for one LOAD statement but I am not sure if it will work with whole script (more LOAD statements). Can I put more load statements sth like this

IF $(vLastUpdDate = Today(1) THEN

//load your data from DB

LOAD ... FROM...

LOAD ... FROM...

LOAD ... FROM...

LOAD ... FROM...

LOAD ... FROM...

ELSE

exit script;

END IF;

???

sparur
Specialist II
Specialist II

Of course, you can.

prabhu0505
Specialist
Specialist

This is an example from reference manua page no. 502



QV_Table:

SQL SELECT PrimaryKey, X, Y FROM DB_TABLE

WHERE ModificationTime >= #$(LastExecTime)#

AND ModificationTime < #$(BeginningThisExecTime)#;

Concatenate

LOAD PrimaryKey, X, Y FROM File.QVD;

STORE QV_Table INTO File.QVD;



I hope this may be useful.

Not applicable
Author

Hey michal,

How did you achieve this?

For me the exit script will exit from the script and save the qvw with no data.

How can I retain the old data? ie, how can exit from script without saving the document?

Regards,

Robins.

PS: I am reloading the document using QV 9.0 Server Management console.

Anonymous
Not applicable
Author

Hi,

I am trying to do a similar thing.  Test my table and if happy let the standard reloads occur.

But, if my test of the table fails I want to exit the script without saving so that the last good version stays good.

The code below checks that the table has >= 44 million rows.  The IF statement works and exits the script but wipes all content from the current tables. 

I need to keep the content of my QVW if the script exits. 

How do I do this?

LOAD

          ROWCounted;

SQL SELECT COUNT(*) AS ROWCounted

  FROM [HealthCentral].[dbo].[WaitingListHistory];

LET vRowCount =   peek('ROWCounted',0);

IF $(vRowCount) < 44000000000 THEN

     Exit Script;

END IF

Not applicable
Author

Hi John,

In your instance, Prabhu's example would like something like this:

LOAD

          ROWCounted;

SQL SELECT COUNT(*) AS ROWCounted

  FROM [HealthCentral].[dbo].[WaitingListHistory];

LET vRowCount =   peek('ROWCounted',0);

IF $(vRowCount) < 44000000000 THEN

     WaitingListHistory:

     LOAD a, b, c FROM File.QVD (QVD);

ELSE

     WaitingListHistory:

     LOAD

     SQL SELECT a, b, c FROM [dbo].[WaitingListHistory];

END IF

STORE WaitingListHistory INTO File.qvd (QVD);

Anonymous
Not applicable
Author

Michael,

thank you for the reply. 

In this instance I am looking for indicators that the source table is incomplete.  Where I believe this to be the case I want to cancel the reload process entirely and keep the last loaded data.

There was reference to using Error Codes to trigger an exit without save and I was hoping someone had an example like that.

Cheers,

John.

Not applicable
Author

I see.  That does sound like a neater solution if you have multiple tables to check and load.