Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

ODBC connection time out- reconnect

Qlikview application connects to DB via odbc connection. Sometimes it fails due to connection time out.

Is there a way to have a loop function in the script to try to connect and execute 'ODBC Connect' statement  until a successful connection is established?

Thanks

<Update>

I tried to execute the below code in my script to  have looping functionality for ODBC connection:

//Script Begins

Let vConnect=1

do while vConnect=1

ODBC Connect To testDB;

If ScriptError=0 THEN

Let vConnect=2;

Endif;

loop;

//Script Ends

The above script works fine when I reload via Qlikview application instance- it tries to reload again and again until a successful connection is established.

However, when the same script/application is reloaded via QMC(Qlikview Publisher), it tries to connect and if it fails the first time, the reload task doesn't try to connect again - do while.. loop is not executed.The job ends with 'Failed' status.

Is there a way to reload the task again in QMC until a connection is established, with this script or any other setting?

Note: There is a setting in Publisher to set 'Number of re-runs'. However, I don't want to limit the number of re-runs to a fixed value. I want it to be executed as many time as it takes, until a connection is created. I am trying to explore if anyone has tried anyother method?

Message was edited by: prashanthi janakiraman

1 Solution

Accepted Solutions
Not applicable
Author

I added 'Set ErrorMode =0' statement in the beginning and it worked in QMC, further used the settings in publisher to limit run time, so it doesn't run infinitely in case the issue persists for a long time. Thank you.

View solution in original post

4 Replies
marcus_sommer

As far as the connect-statement returned an error you could react on them within if-loops by using ErrorHandling in Qlikview.

- Marcus

Not applicable
Author

I tried to execute the below code in my script to  have looping functionality for ODBC connection:

//Script Begins

Let vConnect=1

do while vConnect=1

ODBC Connect To testDB;

If ScriptError=0 THEN

Let vConnect=2;

Endif;

loop;

//Script Ends

The above script works fine when I reload via Qlikview application instance- it tries to reload again and again until a successful connection is established.

However, when the same script/application is reloaded via QMC(Qlikview Publisher), it tries to connect and if it fails the first time, the reload task doesn't try to connect again - do while.. loop is not executed.The job ends with 'Failed' status.

Is there a way to reload the task again in QMC until a connection is established, with this script or any other setting?

Note: There is a setting in Publisher to set 'Number of re-runs'. However, I don't want to limit the number of re-runs to a fixed value. I want it to be executed as many time as it takes, until a connection is created. I am trying to explore if anyone has tried anyother method?

marcus_sommer

I don't know the publisher but maybe there are further settings to ignore the errormode or not.

- Marcus

Not applicable
Author

I added 'Set ErrorMode =0' statement in the beginning and it worked in QMC, further used the settings in publisher to limit run time, so it doesn't run infinitely in case the issue persists for a long time. Thank you.