
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Drop table only if it exists
Hello experts,
In a .qvw I created a QV table inside a condition statement.
Opening binary the above one in another .qvw file, I need to check if the QV table has been created.
Is there a way to check if a QV table exists before calling a drop table statement ?
Thanks in advance.
Best regards
.png)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
There is a system field called $Table which stores all actually loaded tables, so checking this field (with peek(), for exmple) for that table value should work for you.
Hope that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
If the table has a key column, you can do something like.
LET IsFieldAvailable = peek('keyColumn');
IF IsFieldAvailable THEN
DROP TABLE myTable;
END IF;
Lucas Blancher
BizXcel Inc.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
The following should work:
if noOfRows('tablename') > 0 then
drop table tablename;
end if
regards
/Fredrik


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Other way is to set the errormode variable appropriately so in case of error, it skips it and not terminate. Something like:
Set ErrorMode = 0; //Set it to skip error
DROP Table xyz;
Set ErrorMode = 1; //Set it back to standard
.png)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here you are another one, maybe more practical, using system function TableName()
If (len(TableName('YourTable')) > 0) Then Drop Table YourTable; End If

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
great solution but small correction:
If (len(TableNumber('YourTable')) > 0) Then Drop Table YourTable; End If

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello ,
The solution set errormode = 0 worked for me!
Other solutions fail because the table can't be checked on rows etc while it is simply not existing!
Thanks!
