Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Data server is not available. How to exit script without error?

Hi,

Using VBScript I managed QV to reload data automatically on document opening. However, SQL server, where data resides, is not always available. How can I check availability before reloading or to interrupt the script with MsgBox("Server is not available", OK), without hanging up?

Thanks!

1 Solution

Accepted Solutions
disqr_rm
Valued Contributor III

Data server is not available. How to exit script without error?

Try playing with ErrorMode variable:


// Some logic you may have here
SET ErrorMode = 0;
Do your ODBC/OLEDB connection
Do your Selection
if ScriptError > 1 then
// Error handler
SET ErroreMode = 1;
exit script;
end if
SET ErroreMode = 1;
// Further processing



Possible ScriptError values and it's description


1 No error
2 General Error
3 Syntax Error
4 General ODBC Error
5 General OLE DB Error
6 General XML Error
7 General HTML Error
8 File Not Found
9 Database Not Found
10 Table Not Found
11 Field Not Found
12 File Has Wrong Format


In your case, if SQL is not available, you should get either 4 or 5, depending on how your connection string is setup.

Hope this helps you.

4 Replies
disqr_rm
Valued Contributor III

Data server is not available. How to exit script without error?

Try playing with ErrorMode variable:


// Some logic you may have here
SET ErrorMode = 0;
Do your ODBC/OLEDB connection
Do your Selection
if ScriptError > 1 then
// Error handler
SET ErroreMode = 1;
exit script;
end if
SET ErroreMode = 1;
// Further processing



Possible ScriptError values and it's description


1 No error
2 General Error
3 Syntax Error
4 General ODBC Error
5 General OLE DB Error
6 General XML Error
7 General HTML Error
8 File Not Found
9 Database Not Found
10 Table Not Found
11 Field Not Found
12 File Has Wrong Format


In your case, if SQL is not available, you should get either 4 or 5, depending on how your connection string is setup.

Hope this helps you.

Not applicable

Data server is not available. How to exit script without error?

Rakesh,

Thank You so much!

Here is a look of my script (beta version Smiley Happy )


Set some_local_variables;
Set ErrorMode = 0;
ODBC CONNECT TO Database;
SQL SELECT Some, Fields FROM Table1;
STORE Table1 INTO Table1.qvd;
DROP Table1;
//The same with other tables.
Set ErrorMode = 1;
LOAD all_tables FROM qvd_files;


This way I have data loaded from last successful connection with data server. At this time, I have two questions:

1. There is a timeout (45 sec.) at the beginning of the script. To reduce it, I could run "PING DataServer_IP_address" into VBScript and exit script if no answer, but I can't find the syntax of command;

2. Please suggest me a manual where I can read for this!

Thank You again!

disqr_rm
Valued Contributor III

Data server is not available. How to exit script without error?

For your "ping" requirement, see enclosed app.

You can have this on "Open Document" trigger and based on the return variable value, you can continue with the script or not. I am sure some adjustments will be needed, but this will give you some ideas.

Not applicable

Data server is not available. How to exit script without error?

"Wow!" and some pings was in my head when I saw your code Smiley Happy I need some time to discover what happens. Thank you again!

Community Browser