Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

On post reload fail script

Hi,

Is there any way to fail a script only at then end of execution?

We have a script which should not fail until it runs the entire script so we set errormode=0 but in case of failure we have to open the log and check line by line. Please suggest a way to track the error and display it at the end of the log.

Thanks in advance

8 Replies
agni_gold
Specialist III
Specialist III

Can you please explain your question ? , you want to fail your script at the end of execution?

Am i correct ?


Not applicable
Author

Hi Agnivesh,

Yes, that is right.

Thanks

agni_gold
Specialist III
Specialist III

apply any unknown charecter at the last of the script. It will fail

agni_gold
Specialist III
Specialist III

I have used simple a load statement

X:

LOAD A,
B,
C
FROM

(
ooxml, embedded labels, table is Sheet1);

DROP TABLE N;

when this script will run then it will give the error for table not fount and this will also captured in the log file , i have attached the log file screenshot .

Or

If you want other thingh then tell me 

aveeeeeee7en
Specialist III
Specialist III

Hi

Try Using Errormode=2

Hope that helps you.

Regards

Av7eN

Not applicable
Author

Hi Nirmal,

I would propose following solution

After each statement in load script you can check error an store them in table. As a result you will have loaded data and table with errors.

For example define following procedure

SUB checkForError (vScriptError, vScriptErrorDetails)

    //saving error code if error occurred

    IF vScriptError > 0 THEN

        LET vErrorCode = vScriptError ;

        LET vErrorMessage = replace(vScriptErrorDetails, chr(39), '"');  //if errormessage looks like " '<filename>' file not found"  we should replase (') with (")

        CALL writeLog (vErrorCode, vErrorMessage);

    END IF

    ;

END SUB

;

Call this procedure after each operator in your script

CALL checkForError(ScriptError, ScriptErrorDetails);

Don't forget to prepare procedure for writing log in table

SUB writeLog (vStatus, vMessage)

    LET vStopLogTime = now();

     LoadingLog:

    LOAD

         '$(vStopLogTime)'                  AS [StopTime],

          '$(vStatus)'                    AS [Status],

        '$(vMessage)'                     AS [ErrorMessage]

    AUTOGENERATE(1);

END SUB

;

Not applicable
Author

Hi,

Let me try that.

Thanks

Not applicable
Author

Thanks everyone for your valuable inputs.

I have used ScriptErrorCount and alert service to notify admin in case of failure.