Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there,
assuming a generic load created tables called e.g. like this:
Value_at_0,5_bar_[l/min]
Value_at_[°KW]
(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,
Martin
Please have a look here.
http://www.qlikviewaddict.com/2014/06/dropping-tables-using-wildcard.html
You could try switching to wrapping the table name with graves accent - ` - chr(96)
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
END IF
NEXT
// Clear the variables so they don't persist
LET vExpression = null();
LET vCurrTable = null();
END SUB
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.
Hi Evan,
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.
Thanks again,
Martin
Hello Martin,
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?
Hi Evan,
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. 🙂
Cheers,
Martin