mcrist Posted June 18, 2010 Share Posted June 18, 2010 Hi,is it possible do query depending on parameter?exampleIF($P{my_parameter}.equals("TEST"))THEN SELECT * FROM MY_TABLE WHERE MYTABLE.name = $P{my_parameter}ELSE SELECT * FROM TEST_TABLE Link to comment Share on other sites More sharing options...
slow Posted June 18, 2010 Share Posted June 18, 2010 oh... this is a good dilemma... and i like it.I suppose that you assume that the two (or more) tables have the same structure... ok?I think also tha the text you typed isn't in a sql standard format... so it isn't correct.you can obtain a similar result (I have tried it and it works fine ! :) ) with a little trick:define two string parameters:"table_name" with default value: "TEST_TABLE"and "where_sql" with default value: " 1=1"then you can declare the sql query as:select * from $P!{table_name} where $P!{where_sql}(NOTE the $P! syntax and the use of default values... without them you can't have any filed available to create the report layout)now, try to design you report and...then, you can run it passing the table name you prefer, with the where-clauses you want...obviously , the field you use in the report layout must be present in all tables wich name you want to pass as parameter_________________________________________if it works... give me KARMA points please! : ) _________________________________________listening: The Rentals - Friends of P. "If you're down with P. Well, then you're down with me.If you're friends with P. Well, then you're friends with me." (t.r.)in this case P stand for IReport $P .... :) dimenticavo... forza italia! ... quella vera.Post Edited by slow at 06/18/2010 12:03 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