Sometimes, within the loadscript, I need to check if a QlikView table exists or not. Most often this is done after bringing in a separate QlikView document's data with a BINARY statement and I don't know exactly which tables are included in the older document. Sometimes I just need to check if a QlikView table was successfully created earlier in the loadscript.
Here's the way I do it:
If NoOfRows('TABLE_1') > 0 then
//Put statements here to be
//used if TABLE_1 exists
Else
//Put statements here to be
//used if TABLE_1 does not exist
End If
* * *
QlikviewNotes has moved!
-
My QlikviewNotes blog has relocated to the Qlikview Cookbook site. All
links to the qlikviewnotes.blogger.com site have been automatically
redirected to th...
10 years ago
6 comments:
Alos see why QlikView -A need based Comparision at
www.qlikviewvsolap.blogspot.com
Another Possibility:
sub tableExists(inputTabName, exists)
exists=false();
for a=0 to NoOfTables()-1
vTabName = TableName(a);
TRACE Vorhandene Table: $(vTabName);
if ('$(vTabName)' = '$(inputTabName)') then
exists=true()
end if
next
if (exists = true()) then
TRACE Table '$(inputTabName)' exists;
else
TRACE Table '$(inputTabName)' does NOT exist;
end if;
end sub
I doubt this will work when we have a table created but it does not have any row.
set f_does_table_exist =IF ( IsNull ($1), 'N', IF ( IsNull (TableNumber($1)), 'N', 'Y' ) ) ;
usage:
IF $(f_does_table_exist('tablename')) = 'Y' THEN 'it exists' ELSE 'it doesnt' ;
How to check if a Map exists?
TableNumber does not work for tables loaded with mapping load
A mapping load is transient for the whole duration of a script. Therefore, if you have created it, it exists until the script has completed.
Therefore 'drop table' for a map table would generate an error.
If you go to the Menu: Settings > User Prefs > General tab: tick in "Keep Progress Open after Reload", you should also be able to see all tables being loaded including the map table.
Post a Comment