Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create a specific message box

Hello to everybody.

I have a next situation. I have to load tables with specific keys but frequently we have cases with missing fields, because the fields in the script of load statement are variables.

So, I’m searching for a solution about this problem and I want to create a message with  “which is the missing fields” in the layout. 

My idea for script is:

SET ErrorMode = 0;

LOAD *

FROM Abc.QVD ;  


I think that I have to create a “IF” statement where ScriptError = 11 then ……… .

But I don’t know how to continue.

I’m not sure that is the right way, so please give me an advice .

1 Solution

Accepted Solutions
iliyansomlev
Partner - Creator II
Partner - Creator II

Hi,
ScriptErrorDetails does not survive reload or contains info about the last error only (I am using QV 11.2 SR5) .
You have to take the information in it during script run.
ScriptErrorDetails keeps only the detail for the last error that occurred.
For example if you run the script below, you will have only the error detail about the missing txt file even though ScriptErrorCount will be 2.
If you uncomment the last 3 lines the error detail about the Table not Found will also get saved - concatenated to the table ErrorDetailTable.
In similar way you have to save the value of ScriptErrorDetails after each block of code where error may occur and you will have the info you want in the table ErrorDetailTable.
Note that it is written as '$(ScriptErrorDetails)'
Hope this helps;
ErrorMode =0;

MapErrors:
Mapping LOAD * INLINE [
    ErrorCode, Errors
    0, No error
    1, General error
    2, Syntax error
    3, General ODBC error
    4, General OLE DB error
    5, General custom database error
    6, General XML error
    7, General HTML error
    8, File not found
    9, Database not found
    10, Table not found
    11, Field not found
    12, File has wrong format
    13, BIFF error
    14, BIFF error encrypted
    15, BIFF error unsupported version
    16, Semantic error

]
;
//this should return error - cannot find file user2.txt
Errors:
LOAD ErrorCode, Errors
FROM

(
txt, codepage is 1251, embedded labels, delimiter is ' ', msq);
//this will create table to keep the info about the last error that has occurred
ErrorDetailTable:
LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,
'$(ScriptErrorDetails)'
as ErrorDetails
AutoGenerate(1);
//this should give another error - Table not found, no other details here
DROP TABLE TTT;
//uncomment this to save the information about the second error as well
//LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,
// '$(ScriptErrorDetails)'
as ErrorDetails
//AutoGenerate(1);

View solution in original post

1 Reply
iliyansomlev
Partner - Creator II
Partner - Creator II

Hi,
ScriptErrorDetails does not survive reload or contains info about the last error only (I am using QV 11.2 SR5) .
You have to take the information in it during script run.
ScriptErrorDetails keeps only the detail for the last error that occurred.
For example if you run the script below, you will have only the error detail about the missing txt file even though ScriptErrorCount will be 2.
If you uncomment the last 3 lines the error detail about the Table not Found will also get saved - concatenated to the table ErrorDetailTable.
In similar way you have to save the value of ScriptErrorDetails after each block of code where error may occur and you will have the info you want in the table ErrorDetailTable.
Note that it is written as '$(ScriptErrorDetails)'
Hope this helps;
ErrorMode =0;

MapErrors:
Mapping LOAD * INLINE [
    ErrorCode, Errors
    0, No error
    1, General error
    2, Syntax error
    3, General ODBC error
    4, General OLE DB error
    5, General custom database error
    6, General XML error
    7, General HTML error
    8, File not found
    9, Database not found
    10, Table not found
    11, Field not found
    12, File has wrong format
    13, BIFF error
    14, BIFF error encrypted
    15, BIFF error unsupported version
    16, Semantic error

]
;
//this should return error - cannot find file user2.txt
Errors:
LOAD ErrorCode, Errors
FROM

(
txt, codepage is 1251, embedded labels, delimiter is ' ', msq);
//this will create table to keep the info about the last error that has occurred
ErrorDetailTable:
LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,
'$(ScriptErrorDetails)'
as ErrorDetails
AutoGenerate(1);
//this should give another error - Table not found, no other details here
DROP TABLE TTT;
//uncomment this to save the information about the second error as well
//LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,
// '$(ScriptErrorDetails)'
as ErrorDetails
//AutoGenerate(1);