Using LIKE with parameter expression in query - jasper-reports

I was trying to using the like function in iReport 4.0.1. Checked online but none seem to work.
Currently trying to use:
where name LIKE'%$P!{px_name}%'
also tried
'%$P{px_name}%'
but when running the report it comes up saying 'No document'.
But when using where name =$P{px_name} it works perfectly fine.

Where clause will be same as you have used in first step which is :-
where name LIKE '%$P!{px_name}%'
But as you said report says 'The document has no pages' means the query is returning 0 row so just use the same string in LIKE and run the same query in database. Simplest solution is first run the query in database with LIKE operator , if it returns the rows in database then that should also work in iReport.

Related

Grafana variable section show preview of values although query is wrong

I have a grafana dashboard. In this dashboard i created a variable. The sql query is wrong.
My datasource is : ansdatabase
wrong query : select client from ansdatabase
Right query : select client from clienttable
Strange thing is. When i open variables page and write wrong query and save it. Below page shows preview of values. But there shouldnt be any values there. Also page throws an error that it couldnt find ansdatabase table. It is normal because ansdatabase is not a table name.
You must have done the right query before (select client from clienttable) correct? Grafana keeps the values from the last valid query.

Maximo: Save a dynamic query?

In Maximo 7.6.1.1, I can run a query on work orders with this WHERE clause: reportedby = :user:
When I hit Find the query runs successfully; it filters the records using the currently logged in user.
However, when I go back and look at the WHERE clause, I see that the dynamic variable (:user) has been replaced with a static value (JSMITH).
And when I look at the query table in Toad, I see that the clause has been saved as reportedby = 'JSMITH'.
This is not what I want.
How can I save a query with a dynamic variable?
(Oracle 12c)
You can use the View/Manage Queries dialog to change it back. When you first run it Maximo replaces the bind variables.

How to define and use a parameter in Jasper Studio that is a set of ids?

Does anyone know how to define a parameter in Jasper Studio (Community version 6.3.1 final) that is a collection, such as a Set, and to use that in a postgresql query? For example, this Set could be a set of ids that would then be used in the query.
I do a simple sql query like:
select pg_typeof($P{companyDepartmentIds}) as type
I get the following error after selecting "Read Fields":
It seems like this should be possible, I feel I am missing something. I am not sure where in the Jasper Studio interface I can call this setObject() function. Anyone have any thoughts here?
If defining a collection of parameters can't be done, the only other thing I could think of is I could have the parameter be a String, but it would be understood it would be a comma delimited list of values, then I could use regexp_split_to_table or regexp_split_to_array within the query itself.
I was directed to this link and saw what I needed here:
https://community.jaspersoft.com/blog/tip-multi-select-query-integer-parameter-japser-ireportstudio
Specifically what I was looking for was this part from the website under the "Correct Way:" example
SELECT * from table where $X{IN,id,companyDepartmentIds}

How to populate a dropdown list with Slamdata report

I'm using SlamData to create my report. I followed Slamdata's tutorial to populate a dropdownlist from database. I created a mark down with this query
committer = {!`SELECT DISTINCT idCategory FROM "/demo/ReportDB/TMCMSReportData" ORDER BY idCategory}
It return this error:
Can you show me why I got this error?
The correct query would be:
committer = {!`` SELECT DISTINCT idCategory FROM `/demo/ReportDB/TMCMSReportData` ORDER BY idCategory ``}
Note the use of back-ticks (not single quotes) to escape identifiers (the location in the file system) and the double back-ticks surrounding the Markdown snippet. These changes occurred recently when SlamData was updated to use the latest version of Quasar. It looks like not all documentation on the SlamData website has been updated yet.

Two SQL query inside single JasperReport and populating Data

We are using reports in our web application.
The report is generated using JasperReports.
The problem I am facing is:
My SQL query fetches data based on a where clause:
SELECT * FROM table WHERE level='c'
I can easily show this information inside the iReport.
But I need to fire another query where level='d' and the information for the same needs to be appended to the report with that of level='c'.
I tried grouping both the outputs. But problem is how do I fire two different query while generating the report because I can write only one query in QueryBuilder inside the iReport.
Is there anyway of achieving the same.
In essence:
The report should look like:
Level=C
Name Age Phone number
Level=D
Name Age Phone number
Level D should appear only after level c is completed.
Can anyone please guide.
I finally managed to achieve the same..Grouping the data using level_id..
Initially I was trying to group in a different manner and hence the value was not getting shown..
The same is explained pretty nicely in ireport Ultimate guide-3 document.