ktrinad Posted August 19, 2006 Share Posted August 19, 2006 By: karuppaiah kailasam - karupg How do i a build query at runtime using param 2004-03-17 22:18Is there any way of checking the parameters and build a run time query using the parameters for example select * from address is the simple query and i have the following parameters city_param name_param select * from address where city = $P{city_param} and name = $P{name_param} here, how do i check if city_param is null or empty value .. and if it is empty i want to ignore the city_param like select * from address where name = $P{name_param} is it possible to do this ? By: David Lim - aberrant80 RE: How do i a build query at runtime using p 2004-03-17 23:23If you want it so complex, why don't you generate the SQL query first, then load the .jasper file, and set the query, before filling the data. By: Travis Hoffman - travis_stc RE: How do i a build query at runtime using p 2004-03-18 10:29Alternatively, you can just make the parameter encapsulate more of the query: SELECT * FROM address WHERE city = $P!{city_param} $P!{name_param} Of course, that doesn't work well if it's possible that neither are provided. But then, you could do: SELECT * FROM address $P!{where_clause} and simply pass in 'WHERE city = 'foo' AND name = 'bar'' as the where_clause... Hope that helps! -Travis By: karuppaiah kailasam - karupg RE: How do i a build query at runtime using param 2004-03-18 14:51sorry, i should have mentioned that i need to use the jasper (the compiled jasper designer file) in openreports if i just use jasper (embed with my application) then i can follow the above tips ! the problem i have is, openreport loads the jasper file and allows as to pass some parametes if anything required to generate reports using the jasper file, so i don't get chance to check or validate the parameters passed through openreports .. passing the full where class sounds good, but again if i look at from the end-user point of view, the end-user needs some skills/understanding of SQL !! Thanks karup. By: Chuck Deal - cdeal RE: How do i a build query at runtime using param 2004-03-19 05:57Perhaps you should investigate Scriptlets or a Custom DataSource 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