Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi I am currently using the code below for a decode but getting a null pointer when the value is null. Can someone let me know how I could check to see if the column is null before I do the decode. Below is my code
If not null then do below
(row1.PFR_REGION.equals("GULF"))?"3": (row1.PFR_REGION.equals("SF"))?"2": (row1.PFR_REGION.equals("QUEBEC"))?"6":row1.STATUS
You can just reverse the comparisons if you want row1.Status as the default value:
"GULF".equals(row1.PFR_REGION) ? "3" : "SF".equals(row1.PFR_REGION) ? "2" : "QUEBEC".equals(row1.PFR_REGION) ? "6" : row1.STATUS
Else, if you want an other default value, change the expression like this:
row1.PFR_REGION == null ? "YOUR DEFAULT VALUE" : "GULF".equals(row1.PFR_REGION) ? "3" : "SF".equals(row1.PFR_REGION) ? "2" : "QUEBEC".equals(row1.PFR_REGION) ? "6" : row1.STATUS
You can just reverse the comparisons if you want row1.Status as the default value:
"GULF".equals(row1.PFR_REGION) ? "3" : "SF".equals(row1.PFR_REGION) ? "2" : "QUEBEC".equals(row1.PFR_REGION) ? "6" : row1.STATUS
Else, if you want an other default value, change the expression like this:
row1.PFR_REGION == null ? "YOUR DEFAULT VALUE" : "GULF".equals(row1.PFR_REGION) ? "3" : "SF".equals(row1.PFR_REGION) ? "2" : "QUEBEC".equals(row1.PFR_REGION) ? "6" : row1.STATUS
Thanks very much it works!