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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

check if table exists

Hi all, i can't get something working in my script and was wondering if anyone can help..

I am reading multiple csv files into a table then concatenating an existing QVD to that table and storing back out (incremental load).

i am trying to get the script to check if the table exists before trying to concatenate the old data. if the table doesnt exist then i want to create an inline table for the old data to concatenate to.

I cant seem o get this right.

an example of what my script looks like..

For each File in filelist ('$(vRawDataDir)Sample_Tx_*.csv')

  Data:

  LOAD

       Date,

       ....,

       ....,

       .....

  FROM [$(File)] (txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Next

//Check if table exists, if not then create inline table

if NoOfRows(Data)=null() then

Data:

Load * inline [

Date

]

;

endif

// Load in old data

If QvdCreateTime('$(vDataDir)Data.qvd')>0 Then

      CONCATENATE (Data)

      LOAD DISTINCT *

      FROM [$(vDataDir)Data.qvd] (qvd);

    Endif

 

Can anyone help please?

11 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Since your inline table is empty, why not just create it every time and forget about the conditional test?

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

thats a good point, thanks Rob!