Generate table report using sql joins in iReport - jasper-reports

SELECT a.CIVIL_ID,a.PAT_NAME,a.SEX,a.PAT_NAT_CD,a.BIRTH_DT,a.ADDR,a.MOBILE_NO,b.FILE_NO,b.CREATED_DATE
FROM PAT_MST a
JOIN PATIENT_FILE b ON (a.PATIENT_ID = b.PATIENT_ID)
AND( b.HOSP_DEPT_SEC_SERIAL = $P{P_HOSP_DEPT_SEC_CD})
AND a.SEX = DECODE($P{P_GENDER},'ALL',a.SEX,$P{P_GENDER})
AND TRUNC(B.CREATED_DATE)>= TO_DATE($P{P_FILE_CR_DT_FROM},'DD/MM/RRRR') AND TRUNC(B.CREATED_DATE) <= TO_DATE($P{P_FILE_CR_DT_TO},'DD/MM/RRRR')
I am using this query to generate a table report in iReport(5.6.0), but for some reason I am only getting the column headers but this query is returning records when I run on toad.
Please tell where I am wrong..

Are you using Table report element? If so, you are using not the main dataset but some other subdataset. You should transfer parameters values from the main dataset to the one of which your table "feeds".
Add to your subdataset a parameter for an every parameter, used in main dataset.
Right click on your table Edit table dtasource->select Parameters tab->click Add.
In the Add/modify parameter window select your subdataset parameters in the upper menu. In the lower menu select their values (correspondent parameter from main dataset). Do this for an every parameter.

Related

Set command parameter of a subreport equal to a main report parameter

In my main report, I insert a number for column ID into the selection criteria. It grabs all relevant information where the ID matches.
Now I have a subreport that uses a COMMAND with a SQL Query. Inside, there is a WHERE clause where ID = {?PM-ID}.
How can I configure my SQL Query to pull in the specific ID value I entered into the selection Criteria of the main Report?
Try this, right click on Subreport > Change Sub reports Links
In that window you have to match the ID with the respective column in your sql query.

Need help in report's dataset

I'm using iReport Professional 5.1.0. I already used one query (some select query) in report query. But i need to use multiple queries in same report. So i tried with dataset. After creating dataset (Report Inspector -> right click Add Dataset), I've created different query. But i cant get any parameters (which is assigned to parent query column) to the newly created dataset.
My doubt is whether the dataset is applicable only to table, chart and crosstabs. If no, then explain step by step procedure to use dataset in iReport.
Parameters should be in each datasets so just copy the parameters from parent dataset and paste it in all the datasets and when you use any sub dataset for any chart, table or crosstables just pass all parameters and Expression for that parameter.

how to avoid cascading in ssas parameters in ssrs report and load default "all" when report loads?

i have a ssrs report which uses ssas data source and all of the parameter in report also come from ssas data source. the problem is parameters are acting as cascading parameters. i can not have values in parameter drop-down until i select parameter from previous drop-down.
i wanted to have default value "All" selected when report loads instead of waiting for selecting first parameter and then load subsequent?
i have removed #parameters from parameter data source and now here is how my MDX looks like:
WITH MEMBER
[Measures].[ParameterCaption] AS [Category].[Category ID].CURRENTMEMBER.MEMBER_CAPTION MEMBER
[Measures].[ParameterValue] AS [Category].[Category ID].CURRENTMEMBER.UNIQUENAME MEMBER
[Measures].[ParameterLevel] AS [Category].[Category ID].CURRENTMEMBER.LEVEL.ORDINAL
SELECT
{
[Measures].[ParameterCaption],
[Measures].[ParameterValue],
[Measures].[ParameterLevel]
} ON COLUMNS ,
[Category].[Category ID].ALLMEMBERS
ON ROWS FROM
( SELECT ( [OwningEntity].[Entity ID] )
ON COLUMNS FROM
( SELECT ( [Organization].[Organization] ) ON COLUMNS FROM [PerformanceScores]
))
Create Additional data source , point your first parameter with default value "from query" to that data source - This parameter need to be on the top of the list as in SSRS order of parameters is important.
- Let me know if you got any problems.
Thanks
Daniel
Create hidden parameter with IIF statement in default value.
in IIF put dummy date - this will not execute the report but will fill all the other parameters.
IIF(yourparameter.value="",dummydate.value,yourparameter.value)
Use this hidden parameter as your "Main" data range but default value will depend on visible parameter value in IIF statement when user can choose the range
This should work...

Passing values from main report to subreport in JasperReports

I have a simple select sql query with 2 parameters that I want it to be in my query text in main report. It returns about 100 values that I want to put in 10 subreports (10 values per subreport). On main report I need to display only one parameter. All the values from query I need to be in subreports. How do I pass them?
Connection to database is returned to me from application, parameter values also. I'm using iReport 4.7.0.
Parameters are attached to the dataset, if you expand the dataset itself, you'll find a section there for parameters, just like in your main report.
You'll need to link the parameters together though, using the connection properties where you're actually using the dataset, eg, in a chart or a table. For example, in the table, you go to the dataset tab of the properties pane, and click on the parameters button to map the parameters between your main report and your sub dataset.
More here.

SSRS two datasets need to use field from one dataset as a parameter in second?

The issue is that the in field that has the data is just one record in the data set pulled from a set stored proc (not touchable).
Then using it as a parameter in the second dataset. Any help would be appreciated.
Add parameter
Select parameter visibility as Hidden
Go to Default Values: (Screenshot of below)
Select "Get values from a query" (and select your first dataset and value field)
In Dataset 2 filter the data with your new parameter
i.e. SELECT * FROM XYZ WHERE ABC IN (#Param)
You can do this using a subreport.
Add a subreport to the main report.
Add a parameter to the subreport.
Open the rdl of the subreport, add a paramter with the same name.
create a dataset in that RDL using your query for example
select * from YourTable where ENTY_KEY = (#param)