dprogrammer Posted August 16, 2007 Share Posted August 16, 2007 Hi, I need to add three fields in a variable to sum their values. If all three fields have values, sum shows correctly, but if any one of them is null, sum is also null. I need to know what is the syntax for checking nulls. I tried thisField.doublevalue()== null? 0 : field.doublevalue but it didnt' work. Also, I tried using / in a division variable , but it is also giving me errors. My syntax was:variable1.doublevalue() / variable2.doublevalue() Thanks in advance. Link to comment Share on other sites More sharing options...
svenn Posted August 16, 2007 Share Posted August 16, 2007 I assume that you actually used $F{Field}.doubleValue() == null ? : 0 : $F{Field}.doubleValue() and $V{Variable1}.doubleValue() / $V{Variable2}.doubleValue() Were Field and Variable are the names of your values. If so what errors are you getting Link to comment Share on other sites More sharing options...
codyjasperForge Posted August 16, 2007 Share Posted August 16, 2007 One option could be to handle null values in your report query, so you don't have to deal with them in your variables. If you are using a SQL query, then try using a DECODE, CASE, or NVL function. There are others also. This seems to me as the best solution because anytime you test for 'null' values, the result is 'null'. For example, $F{field}.equals(null) -> always yields null (if it is true) Same goes for $F{field} == null ? "value1" : "value2" Only if $F{field} has a value will these actually give desired values. (At least from all of my experience w/iReport I have found this to be true.) P.S. Google: "Oracle 10 SQL Reference" (.pdf)It has a lot of useful info. Hope it helps. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now