loyalman Posted July 28, 2006 Share Posted July 28, 2006 Hi all! I have been developing a software and using tool Ireport of Jasper for making some reports. So I have difficuties to put parameters from a class to Ireport. Please tell me how to put them!! If anyone has solutions,Please send me some related codes.Thanks! :) Link to comment Share on other sites More sharing options...
alphabin Posted July 31, 2006 Share Posted July 31, 2006 Hi, I want to know how to pass string parameter to query string for Oracle.I did select * from orders where order_name=$P{order_name}I passed the value thru the prompt.But it is not showing any records.But if I replace same directly in SQL query,it works.can u help me on this. Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted August 1, 2006 Share Posted August 1, 2006 alphabin: It's not clear to me what you want to do.If you need to set a value for parameters in your app, you have to fill the parameters Map passed to the fillReport method of JasperReports. If you need to set a parameter value using your own code when running a report inside ireport, you can modify the parameter default expression using something like: new MyValueProvider().getValue() Where MyValueProvider is an utility class you can write with the method getValue(). Code:public class MyValueProvider { public MyStrangeType getValue() { // ... create my strange default... return my strange default }} loyalman: Your approach is fine. Please note that if you want the query: select * from orders where order_name='test' the value of $P{order_name} must be test and NOT 'test' Giulio Link to comment Share on other sites More sharing options...
alphabin Posted August 2, 2006 Share Posted August 2, 2006 Ok,I am a starter in Jasper Reports.I will explain clearly. I am using iReports for designing.I added a parameter which is of string type and in the report query I made the query as select * from orders where order_name=$P{order_name} when I run the report I entered test when the prompt came for order_name.But it is telling no documents found.But if I replace my query withselect * from orders where order_name='test' I am getting output.when I tested with numbers the output is coming.I tried select * from orders where order_name="'"+$P{order_name}+"'"But binding variable error is coming. My database is Oracle. Link to comment Share on other sites More sharing options...
alphabin Posted August 15, 2006 Share Posted August 15, 2006 giulio wrote:alphabin:It's not clear to me what you want to do.If you need to set a value for parameters in your app, you have to fill the parameters Map passed to the fillReport method of JasperReports.If you need to set a parameter value using your own code when running a report inside ireport, you can modify the parameter default expression using something like:new MyValueProvider().getValue()Where MyValueProvider is an utility class you can write with the method getValue().Code:public class MyValueProvider { public MyStrangeType getValue() { // ... create my strange default... return my strange default }} loyalman: Your approach is fine. Please note that if you want the query: select * from orders where order_name='test' the value of $P{order_name} must be test and NOT 'test' GiulioThe problem not solved yet.I will explain the thing clearly. I want to pass a value "E17" as parameter to SQL query String. My query is select flno,psta FROM AFTTAB where PSTA=$P{PSTA} My HashMap parameteris ("PSTA","E17") But I cannot get the corresponding pages.But If I eneter query select flno,psta FROM AFTTAB where PSTA='E17'I m getting output. My DB is Oracle.Please help. 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