Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If statement that will cause intentional error in QV script

Hello,

I am solving the problem of reloading 2 tasks - the first task is reloading qvd and storing the number of rows into variable, the second task should have dependency on first and will reload after the first task was successfull.

The problem is that i am not able to make an intentional error in script that will cause task FAILED.

I tried something like this, the first if - task will end SUCCESSFUL

the else - task will end with ERROR:

if vNoofrowsReload > vRowsLast then

execute cmd.exe /c echo OK  > OK.txt;

else

LOAD BLABLA from BLABLA;

endif;

Table BLABLA does not exist - the script will fail, but it is not wokring on the QV server. Can anbybody help me with the solution?

Thank you.

1 Solution

Accepted Solutions
maxgro
MVP
MVP

load 'THIS IS AN ERROR: .....' from notexists.qvd (qvd);

View solution in original post

18 Replies
avinashelite

you can make use of the QMC task dependence rite?

maxgro
MVP
MVP

load 'THIS IS AN ERROR: .....' from notexists.qvd (qvd);

Not applicable
Author

Yes i use dependence, but I want the reload FAIL (1st task) when there are no new rows and SUCCESS when there are new.

Your suggestions is not helpful, it works in desktop but both if-s FAILED on the server.

swuehl
MVP
MVP

Can you elaborate what you mean with 'not working' and 'FAILED' on the server side?

What do you see in the log files and QMC?

Not applicable
Author

Desktop:

I reload the QVW with this if clause, when everything is ok the reload finish successfully. When rows from last reload = rows from actual load, the error in script occurs (that is as I want).

QV Server:

I reload QVW saved on server in QV desktop client the reload works as I wanted.

If i reload QVW with QMC, the reload task always end with fail, even it the first if clause or second clause. It look like that the server always take only the second clause when I reload it using QMC.

Thanks.

swuehl
MVP
MVP

And how have you defined vNoofrowsReload and vRowsLast variables?

Could you post the document log (from QMC run) / script?

Not applicable
Author

Short log:

13.1.2016 15:25:56:      Execution started.

13.1.2016 15:25:56:      QlikView Version:11.20.12758.0

13.1.2016 15:25:56:      CPU Target                    x64

13.1.2016 15:25:56:      Operating System              Windows Server (R) 2008 Standard Service Pack 2 (64 bit edition)

13.1.2016 15:25:56:      Wow64 mode                    Not using Wow64

13.1.2016 15:25:56:      MDAC Version                  6.0.6002.18005

13.1.2016 15:25:56:      MDAC Full Install Version     6.0.6002.18005

13.1.2016 15:25:56:      PreferredCompression          2

13.1.2016 15:25:56:      EnableParallelReload          1

13.1.2016 15:25:56:      ParallelizeQvdLoads           1

13.1.2016 15:25:56:      AutoSaveAfterReload           0

13.1.2016 15:25:56:      BackupBeforeReload            0

13.1.2016 15:25:56:      EnableFlushLog                0

13.1.2016 15:25:56:      SaveInfoWhenSavingFile        0

13.1.2016 15:25:56:      UserLogfileCharset            1200

13.1.2016 15:25:56:      OdbcLoginTimeout              -1

13.1.2016 15:25:56:      OdbcConnectionTimeout         -1

13.1.2016 15:25:56:      ScriptWantsDbWrite            false

13.1.2016 15:25:56:      ScriptWantsExe                false

13.1.2016 15:25:56:      LogFile CodePage Used:        1200

...

13.1.2016 15:26:01: 1243  LET vNoofrowsReload=NoOfRows('SalesQTY')

13.1.2016 15:26:01: 1245  NoOfRowsLast:

13.1.2016 15:26:01: 1246  LOAD @1 as noofrowsLast  

13.1.2016 15:26:01: 1247  FROM

13.1.2016 15:26:01: 1248  \\noofrowslast.txt

13.1.2016 15:26:01: 1249  (txt, codepage is 1250, explicit labels, delimiter is ',', msq)

13.1.2016 15:26:01:       1 fields found: noofrowsLast, 1 lines fetched

13.1.2016 15:26:01: 1251  execute cmd.exe /c echo 2885  > noofrowslast.txt

13.1.2016 15:26:01: 1253  LET vRowsLast = Peek('noofrowsLast', 0, 'NoOfRowsLast')

13.1.2016 15:26:01: 1255  if vNoofrowsReload > vRowsLast then

13.1.2016 15:26:01: 1256    execute cmd.exe /c echo OK  > OK.txt

13.1.2016 15:26:01: 1257  else

13.1.2016 15:26:01:         $Syn 1 = Country+Material Number

13.1.2016 15:26:01:         $Syn 2 = Country+Material Number+KEY_Order

13.1.2016 15:26:01:         $Syn 3 = Month+Country

13.1.2016 15:26:01:         $Syn 4 = Month+Country+CustCode

13.1.2016 15:26:01:         $Syn 5 = Month+Country+CustCode+Period

13.1.2016 15:26:01:         $Syn 6 = Month+Country+CustCode+Material Number

13.1.2016 15:26:01:         $Syn 7 = Month+Country+CustCode+Material Number+Year

13.1.2016 15:26:01:         $Syn 8 = $Syn 3+$Syn 4

13.1.2016 15:26:01:         $Syn 9 = $Syn 3+$Syn 4+$Syn 5

13.1.2016 15:26:01:         $Syn 10 = $Syn 1+$Syn 3+$Syn 4+$Syn 6

13.1.2016 15:26:01:         $Syn 11 = $Syn 1+$Syn 3+$Syn 4+$Syn 6+$Syn 7

13.1.2016 15:26:01:         $Syn 12 = $Syn 1+$Syn 3+$Syn 4+$Syn 5+$Syn 6

13.1.2016 15:26:02:         $Syn 13 = $Syn 1+$Syn 2

13.1.2016 15:26:02:         $Syn 14 = $Syn 1+$Syn 2+$Syn 3+$Syn 4+$Syn 6

13.1.2016 15:26:02:         $Syn 15 = $Syn 8+$Syn 10

13.1.2016 15:26:02:         $Syn 16 = $Syn 8+$Syn 10+$Syn 13+$Syn 14

13.1.2016 15:26:02:         $Syn 17 = $Syn 8+$Syn 10+$Syn 11

13.1.2016 15:26:02:         $Syn 18 = $Syn 8+$Syn 9

13.1.2016 15:26:02:         $Syn 19 = $Syn 8+$Syn 9+$Syn 10+$Syn 12

13.1.2016 15:26:02:         $Syn 20 = $Syn 15+$Syn 18+$Syn 19

13.1.2016 15:26:02:         $Syn 21 = $Syn 15+$Syn 17

13.1.2016 15:26:02:         $Syn 22 = $Syn 15+$Syn 16

13.1.2016 15:26:03:         General Script Error

13.1.2016 15:26:03:         Execution Failed

13.1.2016 15:26:03:      Execution finished.

My variables:

LET vNoofrowsReload=NoOfRows('SalesQTY');

NoOfRowsLast:

LOAD @1 as noofrowsLast  

FROM

$(vPathTXT)noofrowslast.txt

(txt, codepage is 1250, explicit labels, delimiter is ',', msq);

execute cmd.exe /c echo $(vNoofrowsReload)  > noofrowslast.txt;

LET vRowsLast = Peek('noofrowsLast', 0, 'NoOfRowsLast');

swuehl
MVP
MVP

Could you add TRACE statements before your if statement to check the actual values of the two variables?

Not applicable
Author

When the else clause:

2016-01-13 20:42:12 1243 TRACE LET vNoofrowsReload=NoOfRows('SalesQTY')

2016-01-13 20:42:12 1243 LET vNoofrowsReload=NoOfRows('SalesQTY')

2016-01-13 20:42:12 1244

2016-01-13 20:42:12 1245 NoOfRowsLast:

2016-01-13 20:42:12 1246 LOAD @1 as noofrowsLast   

2016-01-13 20:42:13 1247 FROM

2016-01-13 20:42:13 1248 \\noofrowslast.txt

2016-01-13 20:42:13 1249 (txt, codepage is 1250, explicit labels, delimiter is ',', msq)

2016-01-13 20:42:13       1 fields found: noofrowsLast,

2016-01-13 20:42:13      1 lines fetched

2016-01-13 20:42:13 1251 execute cmd.exe /c echo 20  > noofrowslast.txt

2016-01-13 20:42:13 1253 TRACE LET vRowsLast = Peek('noofrowsLast', 0, 'NoOfRowsLast')

2016-01-13 20:42:14 1253 LET vRowsLast = Peek('noofrowsLast', 0, 'NoOfRowsLast')

2016-01-13 20:42:14 1254

2016-01-13 20:42:14 1255 if vNoofrowsReload > vRowsLast then

2016-01-13 20:42:14 1256

2016-01-13 20:42:14 1258   LOAD 'This is an error' from notexists.qvd(qvd)

2016-01-13 20:42:14        Error: Cannot open file '\\notexists.qvd' The system cannot find the file specified.

2016-01-13 20:42:14       

2016-01-13 20:42:56 1259 endif

2016-01-13 20:42:56      $Syn 1 = CountryCode+Material Number

2016-01-13 20:42:56      $Syn 2 = CountryCode+Material Number+KEY_Order

2016-01-13 20:42:56      $Syn 3 = Month+CountryCode

2016-01-13 20:42:57      $Syn 4 = Month+CountryCode+CustCode

2016-01-13 20:42:57      $Syn 5 = Month+CountryCode+CustCode+Period

2016-01-13 20:42:57      $Syn 6 = Month+CountryCode+CustCode+Material Number

2016-01-13 20:42:57      $Syn 7 = Month+CountryCode+CustCode+Material Number+Year

2016-01-13 20:42:57      $Syn 8 = $Syn 3+$Syn 4

2016-01-13 20:42:58      $Syn 9 = $Syn 3+$Syn 4+$Syn 5

2016-01-13 20:42:58      $Syn 10 = $Syn 1+$Syn 3+$Syn 4+$Syn 6

2016-01-13 20:42:58      $Syn 11 = $Syn 1+$Syn 3+$Syn 4+$Syn 6+$Syn 7

2016-01-13 20:42:58      $Syn 12 = $Syn 1+$Syn 3+$Syn 4+$Syn 5+$Syn 6

2016-01-13 20:42:58      $Syn 13 = $Syn 1+$Syn 2

2016-01-13 20:42:58      $Syn 14 = $Syn 1+$Syn 2+$Syn 3+$Syn 4+$Syn 6

2016-01-13 20:42:59      $Syn 15 = $Syn 8+$Syn 10

2016-01-13 20:42:59      $Syn 16 = $Syn 8+$Syn 10+$Syn 13+$Syn 14

2016-01-13 20:42:59      $Syn 17 = $Syn 8+$Syn 10+$Syn 11

2016-01-13 20:42:59      $Syn 18 = $Syn 8+$Syn 9

2016-01-13 20:43:00      $Syn 19 = $Syn 8+$Syn 9+$Syn 10+$Syn 12

2016-01-13 20:43:00      $Syn 20 = $Syn 15+$Syn 18+$Syn 19

2016-01-13 20:43:00      $Syn 21 = $Syn 15+$Syn 17

2016-01-13 20:43:01      $Syn 22 = $Syn 15+$Syn 16

2016-01-13 20:43:13      Execution finished.

When the first if clause:

2016-01-13 20:51:46 1243 TRACE LET vNoofrowsReload=NoOfRows('SalesQTY')

2016-01-13 20:51:46 1243 LET vNoofrowsReload=NoOfRows('SalesQTY')

2016-01-13 20:51:46 1244

2016-01-13 20:51:46 1245 NoOfRowsLast:

2016-01-13 20:51:46 1246 LOAD @1 as noofrowsLast   

2016-01-13 20:51:47 1247 FROM

2016-01-13 20:51:47 1248 \\noofrowslast.txt

2016-01-13 20:51:47 1249 (txt, codepage is 1250, explicit labels, delimiter is ',', msq)

2016-01-13 20:51:47       1 fields found: noofrowsLast,

2016-01-13 20:51:47      1 lines fetched

2016-01-13 20:51:47 1251 execute cmd.exe /c echo 20  > noofrowslast.txt

2016-01-13 20:51:48 1253 TRACE LET vRowsLast = Peek('noofrowsLast', 0, 'NoOfRowsLast')

2016-01-13 20:51:48 1253 LET vRowsLast = Peek('noofrowsLast', 0, 'NoOfRowsLast')

2016-01-13 20:51:48 1254

2016-01-13 20:51:48 1255 if vNoofrowsReload > vRowsLast then

2016-01-13 20:51:48 1256

2016-01-13 20:51:48 1258   LOAD 'This is an error' from notexists.qvd(qvd)

2016-01-13 20:51:48        Error: Cannot open file '\\notexists.qvd' The system cannot find the file specified.

2016-01-13 20:51:48       

2016-01-13 20:51:54 1259 endif

2016-01-13 20:51:54      $Syn 1 = CountryCode+Material Number

2016-01-13 20:51:54      $Syn 2 = CountryCode+Material Number+KEY_Order

2016-01-13 20:51:54      $Syn 3 = Month+CountryCode

2016-01-13 20:51:55      $Syn 4 = Month+CountryCode+CustCode

2016-01-13 20:51:55      $Syn 5 = Month+CountryCode+CustCode+Period

2016-01-13 20:51:55      $Syn 6 = Month+CountryCode+CustCode+Material Number

2016-01-13 20:51:55      $Syn 7 = Month+CountryCode+CustCode+Material Number+Year

2016-01-13 20:51:55      $Syn 8 = $Syn 3+$Syn 4

2016-01-13 20:51:55      $Syn 9 = $Syn 3+$Syn 4+$Syn 5

2016-01-13 20:51:56      $Syn 10 = $Syn 1+$Syn 3+$Syn 4+$Syn 6

2016-01-13 20:51:56      $Syn 11 = $Syn 1+$Syn 3+$Syn 4+$Syn 6+$Syn 7

2016-01-13 20:51:56      $Syn 12 = $Syn 1+$Syn 3+$Syn 4+$Syn 5+$Syn 6

2016-01-13 20:51:56      $Syn 13 = $Syn 1+$Syn 2

2016-01-13 20:51:57      $Syn 14 = $Syn 1+$Syn 2+$Syn 3+$Syn 4+$Syn 6

2016-01-13 20:51:57      $Syn 15 = $Syn 8+$Syn 10

2016-01-13 20:51:57      $Syn 16 = $Syn 8+$Syn 10+$Syn 13+$Syn 14

2016-01-13 20:51:57      $Syn 17 = $Syn 8+$Syn 10+$Syn 11

2016-01-13 20:51:58      $Syn 18 = $Syn 8+$Syn 9

2016-01-13 20:51:58      $Syn 19 = $Syn 8+$Syn 9+$Syn 10+$Syn 12

2016-01-13 20:51:59      $Syn 20 = $Syn 15+$Syn 18+$Syn 19

2016-01-13 20:51:59      $Syn 21 = $Syn 15+$Syn 17

2016-01-13 20:51:59      $Syn 22 = $Syn 15+$Syn 16

2016-01-13 20:52:12      Execution finished.

Do you see something in the logs?

Thank you very much