Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
florian_bertsch
Contributor III
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

2 Solutions

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

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

View solution in original post

kevincase
Creator II
Creator II

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;

View solution in original post

2 Replies
dplr-rn
Partner - Master III
Partner - Master III

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
Creator II
Creator II

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;