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: 
datanibbler
Champion
Champion

Delete remaining tables without exact knowledge?

Hi,

is there any way in QlikView that I can delete all temp_tables that might remain after one iteration of a subroutine, without knowing their exact name (the name is different depending on the iteration in which they were created)?

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Actually TableName() is zero based, and you need to go backwards so that TableName(i) is not affected by the earlier run (otherwise it will skip every second table to be deleted):

For zi = NoOfTables() - 1 To 0 Step -1

  Let vTable = TableName(zi);

If WildMatch(vTable, 'temp*') Then

       DROP Table $(vTable);

  End If

Next

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

4 Replies
marcus_sommer

Hi DataNibbler,

if you used a table prefix like 'temp' - you could run a loop through all tables like:

for i = 1 to nooftables()

     if left(tablename($(i)), 4) = 'temp' then

          drop tables tablename($i));

     end if

next

- Marcus

datanibbler
Champion
Champion
Author

Hi Marcus,

that core_statement (the >> DROP TABLES ... <<) does not seem to work. The editor underlines the back_part

( >> tablename($(i)) <<)

and I get an error that the table in the DROP statement was not found

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Actually TableName() is zero based, and you need to go backwards so that TableName(i) is not affected by the earlier run (otherwise it will skip every second table to be deleted):

For zi = NoOfTables() - 1 To 0 Step -1

  Let vTable = TableName(zi);

If WildMatch(vTable, 'temp*') Then

       DROP Table $(vTable);

  End If

Next

HTH

Jonathan

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

Thanks Jonathan!

That works.

I need that as an interim - in the long run, maybe I will see where and why these tables are created - actually, every table created in my subroutine is supposed to be deleted, I store away the important info and use it afterwards.

It's just that I have no time to look at everything in detail any more than I have to - I have to concentrate on getting this thing in the air ...

Best regards,

DataNibbler