Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Storing the 'ScriptError' value in a variable

Hi everyone,

Does anyone know how to do this???

i have tried;

LET vScriptError = ScriptError;

This doesn't work! Any ideas?

Cheers

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi guys

Thanks for all your help, but i've decided to go with this and it works well.

set ErrorMode=0;

load * from abc.qvw; //considering that abc.qvw doesn't exist

ErrorLog:

LOAD

'$(ScriptErrorCount)'
as vScriptErrorCount,

'$(#ScriptError)'
as vScriptErrorNo,

'$(ScriptError)'
as vScriptError,

'$(ScriptErrorDetails)'
as vScriptErrorDetails

AutoGenerate(1);

View solution in original post

7 Replies
erichshiino
Partner - Master
Partner - Master

Hi,

This piece of code works:

set ErrorMode=0;

  load * from abc.qvw; //considering that abc.qvw doesn't exist

  let var =  ScriptError;

Regards,

Erich

Anonymous
Not applicable
Author

Hi Erich

That does work, but i am looking for the ScriptError number as well as the ScriptErrorDetails.

let var =  ScriptError;

let var1 =  ScriptErrorDetails;

var = 'File Not Found' not '8'

var1 = 'null' not 'Cannot open file...etc'

Any ideas??

erichshiino
Partner - Master
Partner - Master

Ok, I got what happened to ScriptError. Apparently, the data type is dual ( number and string).

You can get the 8 using this:

let var =  num(ScriptError);

For scriptErrorDetails, maybe it will not return a description for this case, since the 'File not Found' might be enough.

According to QV Help, it will return details for errors 3 and 4.

ScriptErrorDetails

Returns a more detailed error description for some of the error codes above. Most importantly this variable will contain the error message returned by ODBC and OLE DB drivers for error codes 3 and 4.

Hope it helps,

Erich

Anonymous
Not applicable
Author

Hi Erich

Thanks for getting back. Yes the Num(ScriptError) worked well!!!

But i don't understand why you can only populate one variable.

If you run the following example var2 is populated, but if you then uncomment var1 then var2 does not update. It's as though the ScriptError variables are reset immediately after the next step??!?!

Can you think of a way of capturing all three variables?

set ErrorMode=0;

 
load * from abc.qvw; //considering that abc.qvw doesn't exist

  //let var1 =  ScriptError;

  let var2ScriptErrorDetails;

 
//let var3 =  num(ScriptError);

CELAMBARASAN
Partner - Champion
Partner - Champion

Script Error is reset if the next executed statement is executed succesfully

You can use the list error details from the ScriptErrorList.

Help File:

ScriptError

Returns the error code of the last executed script statement. This variable will be reset to 0 after each successfully executed script statement. If an error occurs it will be set to an internal QlikView error code. Error codes are dual values with a numeric and a text component.

Anonymous
Not applicable
Author

Hi guys

Thanks for all your help, but i've decided to go with this and it works well.

set ErrorMode=0;

load * from abc.qvw; //considering that abc.qvw doesn't exist

ErrorLog:

LOAD

'$(ScriptErrorCount)'
as vScriptErrorCount,

'$(#ScriptError)'
as vScriptErrorNo,

'$(ScriptError)'
as vScriptError,

'$(ScriptErrorDetails)'
as vScriptErrorDetails

AutoGenerate(1);

CELAMBARASAN
Partner - Champion
Partner - Champion

Thats it. Great!..