asper975 Posted September 8, 2006 Share Posted September 8, 2006 In IReport,I write a query below:select * from student where name in ("smith","lisa","robert") I want to use $P{name} replace ("smith","lisa","robert").and the query change:select * from student where name in ($P{name}) in java code outside:String[] name={"smith","lisa","robert"}parameters.put("name",name.toString());myJPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); But it dosen't work. how to sovle this problem? Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted September 8, 2006 Share Posted September 8, 2006 You have to pass a string containing all your names: Code:String names = "'smith','lisa','robert'";parameters.put("names",names);myJPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); and to use a query like: select * from student where name in ( $P!{names} ) Please note the exclamation mark before $P: in this waynames is not considered a query parameter, but a place order to replace with the content of that parameter.The final query will be created by JR in this way" "select * from student where name in (" +"'smith','lisa','robert'" +" )" Giulio Link to comment Share on other sites More sharing options...
mikij Posted October 21, 2008 Share Posted October 21, 2008 Can someone from JasperReports explain this little bit better ? There is no info about passing array as parameter in your Guide. I want to pass array of Strings, to select some data from database with in (as above), but I also want to define a condition on field or variable based on the input array parameter elements. How can I do this ? e.g., I want to say, if array contain 1, 2 I want to write 0 in my textfield. --Thx, Miki Link to comment Share on other sites More sharing options...
mikij Posted October 23, 2008 Share Posted October 23, 2008 No response to such a simple question :-(. Can PLEASE someone explain how to use array of Long's as Parameter in iReport ? I know that I can say select... in (var) in SQL, but how to pass such Parameter from program and how to define this variable in iReport ? And how can I use this array in field expression condition to check if such array contain some values ? I read the book The Definitive Guide to iReport and some tutorials, but there is nothing about this!--Thx in advance, Miki Link to comment Share on other sites More sharing options...
obedcito_777 Posted July 19, 2014 Share Posted July 19, 2014 aswerquery:from iv030 i,iv004 i4,iv008 i8where i4.va_ide_alm=i.va_ide_alm and i4.va_nom_alm in ($P!{almacenes11})and i.va_exi_can <> 0CODE NETBENASString almacenes="'ALMACEN PROMOTORAS','ALMACEN OUTLET'"; System.out.println("almacenes: "+almacenes); Map mapa=new HashMap(); mapa.put("almacenes11", almacenes);JasperPrint jp=JasperFillManager.fillReport(jr, mapa,con); JasperViewer.viewReport(jp); 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