Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Highlighted
florian_bertsch
New Contributor III

Retrieve status of LIB CONNECT TO 'xxx' in Data Load Editor Script

Hi @all,

I am wondering if it's possible to retrieve the status of a LIB CONNECT TO 'xxx' in the Data Load Editor Script. I need it for:

       LIB CONNECT TO 'xxx';

       IF <status>=error then LIB CONNECT TO 'yyy';

       End If;

Best regards,

Florian

Tags (1)
2 Solutions

Accepted Solutions
Partner
Partner

Re: Retrieve status of LIB CONNECT TO 'xxx' in Data Load Editor Script

never tried it. but i would theorize that you need to use error variables.
https://help.qlik.com/en-US/sense/April2019/Subsystems/Hub/Content/Sense_Hub/Scripting/ErrorVariable...

i.e. set errormode=2
then use ScriptError variable to check and then connect to other db
kevincase
Contributor II

Re: Retrieve status of LIB CONNECT TO 'xxx' in Data Load Editor Script

Florian,
If you want an example, import one of the supplied monitoring applications. For example, License Monitor. They include code to check for the existence of the Logging Database. You could use this as a sample.
Set errormode = 0; // suppress reload failure in case of no database

LIB CONNECT TO 'QLogs';

// If there is an error connecting to logging database...
LET tempErrorDetails = ScriptErrorDetails;
IF Len(tempErrorDetails) > 0 THEN
trace ERROR: $(tempErrorDetails);
CALL monitor_app_reload_stats('WARN','$(textFile)', tempErrorDetails, 'Status Message')
tempErrorDetails =; // Reset this variable
TRACE Could not validate active database logging. Sourcing from file logs instead.;
SET db_v_file = 1;
LET baseTableName = '$(baseTableName)_file'; // Store log history QVD with suffix _file so it only gets used with file logging
LET lastReloadCompare = If(LastReloadSource=1,lastReloadCompare,cutoffDate); // If last reload loaded from db and now from file
// we want to start over and pull data from cutoffdate
TRACE Last Reload Compare time = $(lastReloadCompare). CutoffDate = $(cutoffDate).;
SET errormode=1;
EXIT SUB;
2 Replies
Partner
Partner

Re: Retrieve status of LIB CONNECT TO 'xxx' in Data Load Editor Script

never tried it. but i would theorize that you need to use error variables.
https://help.qlik.com/en-US/sense/April2019/Subsystems/Hub/Content/Sense_Hub/Scripting/ErrorVariable...

i.e. set errormode=2
then use ScriptError variable to check and then connect to other db
kevincase
Contributor II

Re: Retrieve status of LIB CONNECT TO 'xxx' in Data Load Editor Script

Florian,
If you want an example, import one of the supplied monitoring applications. For example, License Monitor. They include code to check for the existence of the Logging Database. You could use this as a sample.
Set errormode = 0; // suppress reload failure in case of no database

LIB CONNECT TO 'QLogs';

// If there is an error connecting to logging database...
LET tempErrorDetails = ScriptErrorDetails;
IF Len(tempErrorDetails) > 0 THEN
trace ERROR: $(tempErrorDetails);
CALL monitor_app_reload_stats('WARN','$(textFile)', tempErrorDetails, 'Status Message')
tempErrorDetails =; // Reset this variable
TRACE Could not validate active database logging. Sourcing from file logs instead.;
SET db_v_file = 1;
LET baseTableName = '$(baseTableName)_file'; // Store log history QVD with suffix _file so it only gets used with file logging
LET lastReloadCompare = If(LastReloadSource=1,lastReloadCompare,cutoffDate); // If last reload loaded from db and now from file
// we want to start over and pull data from cutoffdate
TRACE Last Reload Compare time = $(lastReloadCompare). CutoffDate = $(cutoffDate).;
SET errormode=1;
EXIT SUB;