Jump to content
Changes to the Jaspersoft community edition download ×

Adding text to query with a parameter


2006 IR Open Dicussion

Recommended Posts

By: Vinicius - vqmacedo

Adding text to query with a parameter

2006-03-08 12:15

Hello,

 

Does anybody knows how to add a text to the query, somethig like dynamic filters. Example:

 

report query = select * from table

 

to add "ANDs" using a parameter, I create a $P{filters} and try to put it in the query like:

 

select * from table

$P{filters}

order by field

 

and It doesn't work, even if I use the parameter as Object, because Jasper put '' in String parameters.

 

Is there any method to do this, because I can't pass the JRResultSetDataSource to the report.

 

regards,

 

Vinicius Macêdo

 

 

 

 

 

 

By: cyclistca - cyclistca

RE: Adding text to query with a parameter

2006-03-08 14:51

You want to pass your parameter as a literal string instead of a value.

 

To do this you would use $P!{filter}.

 

select * from table

$P!{filter}

order by field

 

filter would then be assigned the value of your where clause.

 

ie

 

filter = "Where table.a = value and table.b = value"

 

If there are no conditions I will pass my condition as

 

filter = "where 1 = 1"

 

 

 

 

By: Vinicius - vqmacedo

RE: Adding text to query with a parameter

2006-03-09 04:55

Thank you very much. It works nicely.

 

Vinicius

Salvador/Brazil

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...