Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is it possible to conditionally force script execution to end -AND- be treated as an error?
For example, if a query or stored procedure doesn't return any results I would like to end the script execution as an error. I know I can use EXIT SCRIPT but this is treated as a graeful script completion and therefore can't be used to send a failure notification from Publisher et al. unless I am missing something.
Anybody doing anything like this today or have ideas?
Thanks -Isaiah
Hi,
You can use ErrorMode and ScriptError in your script. Look for "ErroMode" in the help.
Thanks qlikuser14 but that's not exactly what I need. I want to be able to be able to set the value of ScriptError myself based on some logic; e.g. a query doesn't return any results (simply because there aren't any records returned; not because of an OLEDB/ODBC error.) I tried using a SET statement to set the value but that doesn't work. Any other ideas?
Thanks -Isaiah
Hi, Isaiah.
It is not an elegant solution, but you could force an error with a wrong statement:
Table:
SQL Exec yourProcedure .... .... ;
if alt( NoOfRows('Table'), 0) < 1 then //I used alt() because NoOfRows was not enough...
asdfkjsdflkks; //or any wrong command
end if
Hope if helps,
Erich
Erich > I love it! I'm all about non-elegant solutions when they're the only option and they function well.
Thanks -Isaiah
Isaiah
I posted an idea a while ago on the Ideas side of the site to allow the script to be conditionally terminated. Please vote for the idea if you think it would help.
http://community.qlik.com/ideas/1956
Regards
Jonathan
Thanks for sharing Jonathan > I don't know why I didn't come across this in my initial query. I voted up on the idea; this would be great functionality. -Isaiah
I have used
let vNoDoclines = NoOfRows('oas_docheadlinesMod');
if IsNull(vNoDoclines) then
trace --- no docline records ---;
Exit script;
ENDIF;
works also
Yes, this can also be used.
The difference is that 'Exit script' will not return an error. You would have a successful task on the server.
That other case would have a failed task.
Thanks!
Erich
Plus the qvw file will be saved with an empty table for the tested table and anything built after the conditional check. If the reload "fails", it should not save the failed file.