Four Stars

Tmap expression causing null error message

I have a source table which has nulls in the fields listed below and lookup table also has null values.

I am using an output filter which is causing the following error message.  How do you fix this issue?

Exception in component tMSSqlInput_7 (PTLoadSateliteJob)
java.lang.RuntimeException: Null value in non-Nullable column.

 

This is the filter I'm using.

 

Name column is String

CTypeId is Integer

StypeId is Integer

OpportunityId is Boolan

StartDate is Datetime

 

(!(row1.Name).equals(row2.Name) ||
row1.CTypeId != row2.CTypeId ||
row1.STypeId != row2.STypeId ||

row1.OpportunityId != row2.OpportunityId ||

row1.StartDate != row2.StartDate)

 

 

4 REPLIES
Fifteen Stars

Re: Tmap expression causing null error message

This is why knowing Java is REALLY useful. Your issue is caused by the fact that an object that is null has no methods (like equals) available. Consider it as not existing. For example, you can say someone is a waste of space, but not a waste of null :-)

 

The way to get round this is to check for null first. For example....

 

row1.myValue!=null && row1.myValue.equals("hello")

The first thing that happens is that myValue is checked for null. If it is NOT null, then the next part is checked. As we know myValue is not null, it will definitely have the ability to use the "equals" method.

Rilhia Solutions
Four Stars

Re: Tmap expression causing null error message

I have a record with field name from source and lookup both have null value.  How do we compare this?

source incoming might change the value to a non null value in future, but for the first run I need to compare null to null.

 

meaning row1.name(null value) <> row2.name(null value)

Seven Stars

Re: Tmap expression causing null error message

Hi ,

In tmap expression filter use and condition for main flow and the lookup so that the null values from the data are eliminated 

 

row1.name!=null && row2.name!=null

where row1 is the main connection and row2 is the lookup connecting to tmap

 

try and let me know 

 

Don't forget to give kudos when a reply is helpful and click Accept the solution when you think 

Fifteen Stars

Re: Tmap expression causing null error message

It sounds like you need something to future proof your code for when you do get values. I have a routine method I put together which should cover your requirements. It does a little more and compares Strings irrespective of case (you may want to change compareToIgnoreCase with equals), but it also handles comparing nulls. Take a look....

 

    public static boolean valuesMatchAcceptNulls(String data1, String data2){
    	boolean returnVal = false;
    	
    	if(data1!=null && data2!=null){
    		if(data1.compareToIgnoreCase(data2)==0){
    			returnVal = true;
    		}
    	}else if(data1==null && data2==null){
    		returnVal = true;
    	}
    	return returnVal;
    }

Create a routine (or add this to an existing routine) and use it in your tMap. 

Rilhia Solutions