Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi community
Your kind help in below issue is highly appreciated...
I have created a sub routine to load a table from database , my sub. looks like:
////// Sub routine to load Qlik table based on sql query
Sub loadFromDb(vTableName, vDbQuery)
$(vTableName):
SQL $(vDbQuery)
STORE $(vTableName) INTO [lib://$(vTableName).qvd] (qvd);
DROP TABLE$(vTableName);
End Sub
//////////////////End code/////////
I am calling this sub by:
////// Calling sub
Let query="select field1, field2 from tableName"
call loadFromDb('qlikTableName', $(query))
////// End calling sub
I am always getting the error "Unknown statement: :select field1, field2 from tableName",
The same code is working fine if not using subroutine
Can you please help me in knowing the cause of this error,
Thanks a lot
Hi, that simle quotes are neede so maybe there is some other place where youneed to use them, which line returns the error? You can addd 'TRACE' sentences to check where it stops.
Some other changes, like using set instead of let, and add missing semicolons.
////// Sub routine to load Qlik table based on sql query
Sub loadFromDb(vTableName, vDbQuery)
$(vTableName):
SQL $(vDbQuery);
STORE $(vTableName) INTO [lib://$(vTableName).qvd] (qvd);
DROP TABLE$(vTableName);
End Sub
//////////////////End code/////////
////// Calling sub
Set query=select field1, field2 from tableName;
call loadFromDb('qlikTableName', $(query))
////// End calling sub
Hi, try addding simple quotes to the query:
call loadFromDb('qlikTableName', '$(query)')
Thank you for ur reply , adding single quotes to the variable changed nothing , i am still getting the same behavior.
Hi, that simle quotes are neede so maybe there is some other place where youneed to use them, which line returns the error? You can addd 'TRACE' sentences to check where it stops.
Some other changes, like using set instead of let, and add missing semicolons.
////// Sub routine to load Qlik table based on sql query
Sub loadFromDb(vTableName, vDbQuery)
$(vTableName):
SQL $(vDbQuery);
STORE $(vTableName) INTO [lib://$(vTableName).qvd] (qvd);
DROP TABLE$(vTableName);
End Sub
//////////////////End code/////////
////// Calling sub
Set query=select field1, field2 from tableName;
call loadFromDb('qlikTableName', $(query))
////// End calling sub
Thank you so much , removing the quotes , and replacing Let with Set solved the problem