Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Throw error based on Database field value

Dear All,

is it possible to load a table according to a database filed value. ie, if the value of that field is zero then it should throw error,else it should run the script.

Raise Error based on DB value

Load

Value

From Xtable;

if value=0,then fail script

8 Replies
chiru_thota
Valued Contributor

Re: Throw error based on Database field value

You can do that. Logic here you will check a condition before running script.

To control this you need to put actual code in the form of sub routines. You can have as many sub routines you want.

Just see attached QVW.

LOAD * INLINE [
CheckValue
1
]
;

Let VEXITCOUNT=Peek('CheckValue',0,'Exit_loop_table');
exit script when VEXITCOUNT = 0; 

IF  VEXITCOUNT > 0 then  

Call CodeScript;

END IF;

Not applicable

Re: Throw error based on Database field value

Hi,

Thank you for your reply, it was very much helpful , will it be possible to throw an error message when that condition not satisfied or else the script execution should be cancelled.

Thanks in advance.

MVP
MVP

Re: Throw error based on Database field value

You can try using Exit Script command conditionally, something like:

If( <condition>) Then

Exit Script;

End If

chiru_thota
Valued Contributor

Re: Throw error based on Database field value

ok.

I guess you will be running this task from QEMC once the development is completed.

Then where do you want to see the message  while QEMC running the QVW?

MVP
MVP

Re: Throw error based on Database field value

replace 1=1 with your condition for error check

set ErrorMode=2;

IF (1=1) THEN

  load * Resident TableNotExists;

ENDIF;

you'll get a in qlik desktop

1.png

on a server you can config to send an alert mail

Not applicable

Re: Throw error based on Database field value

hi,

kindly post me a sample application.

Thanks..

Not applicable

Re: Throw error based on Database field value

hi,

in my application after successful reload it will generate a PDF and send mail using publisher .so my concern is like if the condition doesn't satisfies it wont run the script, it would show error message otherwise it will generate a PDF.

Thankss...

Not applicable

Re: Throw error based on Database field value

Its easy, write an if else statement. If value is 0, ask it to look for file which will never exist. Then the job obviously fails. Use QMEC to send an email if it fails.

Suraj

Community Browser