I am trying to execute the C++ program from the DataStage client. I was getting the following error message.
buildop_200,8: Fatal Error: Null value on the accessor interfacing to field "field1".
Looks like it was receiving the Null values in the coulmn 'field1' from the input file. Even though i am handling the NULL check in my buildop c++ code, it’s still failing when i am running this buildop (C++ code) through the DataStage job.
How to handle NULL values (if column value [c++ varchar/string] is null) gracefully in the Datastage?
This is what I am currently handling in the code….
if (in0.field1[1] == 0 || in0.field1[1] == '\0' || in.field1[1] == ' ') /*** NULL check ****/
{
//C++ logic
}
else
{
if ((in0.field1[1] == 'N') && (in0.field2.substring(1, 2) == in0.Orig_Code))
{
//C++ logic
}
// More C++ logic, if statements
}
Could you please help me with this problem? I apprecite your help in this regard.
First and foremost, please use code tags. On the right-hand side of the text box, there's a button that looks like this: <> Press that and insert your code between the tags.
tjr28 wrote:
in0.field1[1] == 0 || in0.field1[1] == '\0'
These two are exactly the same. The null-character is equivalent to zero.
to access any element from the input file (CSV) within the DataStage we have to use by default in0.coulmn_name (in0.field1 or in0.field2 etc). the type of the field1 is "string" (sql type is varchar), it accepts 1 charecter
the type of the field1 is "string" (sql type is varchar), it accepts 1 charecter
i tried to do the NULL check this way, but still receiving the same error message
if (in0.field1), buildop_200,3: Fatal Error: Null value on the accessor interfacing to field "field1".