Discussion Board for collaboration on QlikView Scripting.
assuming a generic load created tables called e.g. like this:
(Yes, including the square brackets around the unit)
I want to delete them automatically at the end of the load script using the usual for-loop. But I don't find the correct phrasing for the drop statement. Has someone an idea?
Thanks a lot in advance,
Try based on this example
SUB WildcardDropTables (vExpression)
// Loop through the tables within the model
FOR i = 0 TO noOfTables()-1 STEP 1
// Get the current table name
LET vCurrTable = tablename(i); // Get the current table name
// If the table name matches the pattern then drop it
IF wildmatch('$(vCurrTable)','$(vExpression)') THEN
DROP Table [$(vCurrTable)];
LET i = i - 1; // Needed as table index reduces once table is dropped
// Clear the variables so they don't persist
LET vExpression = null();
LET vCurrTable = null();
CALL WildcardDropTables ('*-temp')
That is a nice usage of the wildcard Ramkumar, will have to remember that.
I think if you count backwards from NoOfTables()-1 to 0 you don't have to keep resetting i.
I am afraid the ` won't be accepted. How could a drop table statement look like with the examples above?
My problem is not creating the loop, much more the drop table statement ( I can also write the drop-statements manually behind each other if necessary.
I'm not able to reproduce your issue. I created a variety of tables with programmatic characters embedded in the table names and am able to drop them in a for-loop using the same DROP statement across all tables.
Maybe there are some scenarios I missed or it is a version thing?
thanks a lot for your work.... it is really strange, obviously it SHOULD work... I will investigate further and let you know when I have a result. :-)