use of following command in expression allows to eliminate decide by zero error in jasper. $F{feild_name1} and $F{feild_name2} are fields value return from query. if the denominator ($F{feild_name1}) is equal to 0 then command returns 0. Else this returns $F{feild_name2}.doubleValue() / $F{feild_name1}.doubleValue().
new Double(($F{feild_name1}.doubleValue() == 0.00) ? 0.00 : ($F{feild_name2}.doubleValue() / $F{feild_name1}.doubleValue() * 100))new Double(($F{wave}.toString() == null) ? $F{project} : ($F{project}.toString() + $F{wave}.toString()))
Java servlet use in expression area.
Utils() is the Java class name. com.mycompany.utils is Java package name. filed value is used in Java servlet as a string value and return the output value.
(new com.mycompany.utils.Utils()).hourFormat($F{feild_name2}.toString())Return current date
use of following phase in parameter expression area will set set current date as default parameter value.
new java.util.Date()
Return exact date
use of following phase in parameter expression area will set set "2000- 1- 1" as default parameter value.
new java.util.Date(new GregorianCalendar(2000, 1, 1).getTime().getTime())If, Elsif and Else condition in Jasper
new String(($F{project_type}.toString() == "I") ? "IT" :
(new String(($F{project_type}.toString() == "M") ? "Medical" :
((new String(($F{project_type}.toString() == "C") ? "Consumer" :
((new String(($F{project_type}.toString() == "X") ? "Other/Dont know" :
("- ") )))
)))
)
)
)
I WAS LOOKING FOR THE IF ELSIF CONDITION... THANX FOR SHARING... THIS IS WHERE I USE IT
ReplyDeleteMYSQL QUERY:
SELECT Sum(If($P{ALMACEN} And fecha>=$P{desde} And fecha<=$P{hasta},cantidad,0)) AS entradas, Sum(If(almacen2=$P{ALMACEN} And fecha>=$P{desde} And fecha<=$P{hasta},cantidad,0)) AS salidas, Sum(If(almacen1=$P{ALMACEN} And fecha<$P{desde},cantidad,0))-Sum(If(almacen2=$P{ALMACEN} And fecha<$P{desde},cantidad,0)) AS inventarioinicial, Sum(If(almacen1=$P{ALMACEN} And fecha<=$P{hasta},cantidad,0))-Sum(If(almacen2=$P{ALMACEN} And fecha<=$P{desde},cantidad,0)) AS inventariofinal, proveedores.nombre, productos.cprov, productos.cprod, productos.descripcion
FROM proveedores INNER JOIN (productos INNER JOIN entradas_y_salidas ON (productos.cprov=entradas_y_salidas.cprov) AND (productos.cprod=entradas_y_salidas.cprod)) ON proveedores.cprov=productos.cprov
WHERE (((entradas_y_salidas.cprod)=productos.cprod) And ((entradas_y_salidas.cprov)=productos.cprov))
GROUP BY productos.cprov, productos.cprod, productos.descripcion, proveedores.nombre;
THERE IS THE TABLES "PRODUCTOS", "PROVEEDORES" "ENTRADAS Y SALIDAS" AND IT HELPS ME PRINT OUT THE "ALMACEN" NUMBER AS TEXT WITHOUT HAVING TO MAKE ANOTHER SQL QUERY...
THIS IS JUST AN INVENTORY DATABASE