Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Handling errors in OLEDB CONNECT

I have a OLEDB CONNECT in a scheduled reload that sometimes fails. Is there a way of handling that failure?

I want to be able to use another OLEDB CONNECT if the first one fails.

The only way I can handle failure at the moment is in the QMC job scheduler.

Tags (1)
1 Solution

Accepted Solutions
telepuzik
Not applicable

Re: Handling errors in OLEDB CONNECT

Hi Ashar,

The second ODBC will be used if the first one fails. !

--------------------------------------------------------------------------

set ErrorMode=0;

OLEDB CONNECT32 TO [Provider=MSDASQL.1;Persist Security Info=False;Data Source=MyTest;Extended Properties="DSN=MyTest;DBQ=C:\Temp\Database1.accdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"];

let ErrorNum = num(ScriptError);

Trace ScriptError: $(ErrorNum);

IF ErrorNum > 0 Then

  OLEDB CONNECT32 TO [Provider=MSDASQL.1;Persist Security Info=False;Data Source=MyTest2;Extended Properties="DSN=MyTest2;DBQ=C:\Temp\Database2.accdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"];

ENDIF

[Temp]:

Load

  Client

  , ID

;

SQL SELECT

  Client

  , ID

FROM TClient;

--------------------------------------------------------------------------

Best Regards,

Cyrus

7 Replies
amit_saini
Not applicable

Re: Handling errors in OLEDB CONNECT

Hi Ashar,

Inside QMC go to System->Setup->Select Distribution Services ->Alert E-mail and here mention your email Id. This will  help you for getting automatic alert whenever any task got failed.

Thanks,
AS

Not applicable

Re: Handling errors in OLEDB CONNECT

Hi,

If i was you i would find out what the cause of the failure is. In my mind the following could be the issue:

1. Different connection name: Make sure that the connection name on the server and the development environment is the same.

2. User credentials: Make sure that the user credentials being used on the development machine are valid on the server too.

This could help you eliminate the failure in the first place.

Regards

Rahul

Not applicable

Re: Handling errors in OLEDB CONNECT

Thanks but I got alert emails set up already. I am looking for some way to automatically connect to the second database, if the first one fails.

Not applicable

Re: Handling errors in OLEDB CONNECT

Its a cluster with 2 IP addresses. Sometimes the main server goes down and the OLEDB CONNECT fails.When this happens, I need to connect to the second server.

telepuzik
Not applicable

Re: Handling errors in OLEDB CONNECT

Hi Ashar,

The second ODBC will be used if the first one fails. !

--------------------------------------------------------------------------

set ErrorMode=0;

OLEDB CONNECT32 TO [Provider=MSDASQL.1;Persist Security Info=False;Data Source=MyTest;Extended Properties="DSN=MyTest;DBQ=C:\Temp\Database1.accdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"];

let ErrorNum = num(ScriptError);

Trace ScriptError: $(ErrorNum);

IF ErrorNum > 0 Then

  OLEDB CONNECT32 TO [Provider=MSDASQL.1;Persist Security Info=False;Data Source=MyTest2;Extended Properties="DSN=MyTest2;DBQ=C:\Temp\Database2.accdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"];

ENDIF

[Temp]:

Load

  Client

  , ID

;

SQL SELECT

  Client

  , ID

FROM TClient;

--------------------------------------------------------------------------

Best Regards,

Cyrus

Not applicable

Re: Handling errors in OLEDB CONNECT

Thanks Cyrus! This is what I was looking for

telepuzik
Not applicable

Re: Handling errors in OLEDB CONNECT

You are welcome!