Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I would like to ignore the error when loading a given file (File1) which does not exist but abort the same script if another given file (File2) does not exist.
Here's my load script:
Table1:
LOAD
Param1,
Param2
FROM [$(vConfigPath)File1.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);
Table2:
LOAD
Field1,
Fiel2
FROM [$(vConfigPath)File2.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);
If File1 does not exist I would like the script to continue.
If File2 does not exist I would like the script to abort.
Many thanks in advance.
To ignore any kind of error and be able to react appropriate (querying the ScriptError) you could follow the advise from Sunny (have a look in the help for more details). In your case you could directly query if these files exists or not. Try something like this:
if [$(vConfigPath)File1.csv] then
Table1:
LOAD Param1, Param2
FROM [$(vConfigPath)File1.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);
end if
if [$(vConfigPath)File2.csv] then
Table1:
LOAD Field1, Field2
FROM [$(vConfigPath)File2.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);
else
exit script;
end if
- Marcus
Use this right where you want to ignore an error.
SET ErrorMode = 0;
and right after the code where you know the error comes add this
SET ErrorMode = 1;
To ignore any kind of error and be able to react appropriate (querying the ScriptError) you could follow the advise from Sunny (have a look in the help for more details). In your case you could directly query if these files exists or not. Try something like this:
if [$(vConfigPath)File1.csv] then
Table1:
LOAD Param1, Param2
FROM [$(vConfigPath)File1.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);
end if
if [$(vConfigPath)File2.csv] then
Table1:
LOAD Field1, Field2
FROM [$(vConfigPath)File2.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);
else
exit script;
end if
- Marcus
Hello Sunny,
That's what I thought as well , but for some unknown reason it sill aborts...
Thanks for your help.
Annick