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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
OmarBenSalem
Partner - Champion II
Partner - Champion II

Generic script to delete all tables

Hi all,

After constructing my model (tables); my main purposes were:

1) Store all tables in QVDs:

FOR i = 0 to NoOfTables()-1 

LET vTabName = TableName($(i)); 

STORE $(vTabName) into [lib://blabla/QVD/$(vTabName)$(vSaveFile).qvd] (qvd); 

NEXT i 

2) drop all the tables (after storing them in qvds) :


//drop tables

FOR j = 1 to NoOfTables()

LET vTabName2 = TableName($(j)); 

Drop table "$(vTabName2)";

NEXT j 

The problem is that the first part (storing the tables works perfectly) while the second one does not.

In fact, from the 15 tables I have, some are deleted and nearly the half ARE NOT.


I have tried :

Drop table "$(vTabName2)";

Drop table '$(vTabName2)';

Drop table $(vTabName2);

Drop table vTabName2;



Nothing works as expected...

When I try the same script with inline tables, all is deleted !


Any idea on what could be the cause of such a behaviour? Thanks

1 Solution

Accepted Solutions
agigliotti
MVP
MVP

i'm using the below script in Qlikview that works fine.

LET vL.NumTabelle = NoOfTables();

FOR j=0 to $(vL.NumTabelle)-1

 

LET vL.nomeTabella = TableName(0);

  DROP Table [$(vL.nomeTabella)];

NEXT j;

I hope it helps.

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it

View solution in original post

11 Replies
OmarBenSalem
Partner - Champion II
Partner - Champion II
Author

agigliotti
MVP
MVP

i'm using the below script in Qlikview that works fine.

LET vL.NumTabelle = NoOfTables();

FOR j=0 to $(vL.NumTabelle)-1

 

LET vL.nomeTabella = TableName(0);

  DROP Table [$(vL.nomeTabella)];

NEXT j;

I hope it helps.

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
sunny_talwar
MVP
MVP

Why don't you drop them after storing?

FOR i = 0 to NoOfTables()-1

LET vTabName = TableName($(i));

STORE $(vTabName) into [lib://blabla/QVD/$(vTabName)$(vSaveFile).qvd] (qvd);

DROP Table $(vTabName);

NEXT i

OmarBenSalem
Partner - Champion II
Partner - Champion II
Author

I tried that, and the result was the same

OmarBenSalem
Partner - Champion II
Partner - Champion II
Author

That worked perfectly !

jonathandienst
Partner - Champion III
Partner - Champion III

Count backwards - the TableName($i) is being affected by the Drop Table:

For i = NoOfTables()-1 to 0 Step -1

    LET vTabName = TableName($(i));

    STORE $(vTabName) into [lib://blabla/QVD/$(vTabName)$(vSaveFile).qvd] (qvd);

    DROP Table $(vTabName);

Next


Or always reference the first table:

FOR i = 0 to NoOfTables()-1

    LET vTabName = TableName(0);

    STORE $(vTabName) into [lib://blabla/QVD/$(vTabName)$(vSaveFile).qvd] (qvd);

    DROP Table $(vTabName);

Next

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
OmarBenSalem
Partner - Champion II
Partner - Champion II
Author

when I did this, some data was missing in the qvds !

sunny_talwar
MVP
MVP

I suggest to avoid using Generic load if you plan to combine them... just use loop to create new fields...

hariishr
Contributor III
Contributor III

i am using QLIK SENSE FEB 2020. this worked. thank you