-1

Say, I have a simple report with a data-source setup. I'm going to embed the report in a Java application. In that application the user gives a specific input. That input would get passed into the Report as a parameter. Based on that parameter the report's query should generate results. How this can be achieved ?

Eg..

  1. User is asked for input for a SCHOOL_ID,

  2. SCHOOL_ID is passed as a Parameter to the REPORT,

  3. REPORT puts the SCHOOL_ID's value in the SQL query,

    (SELECT * FROM Students WHERE SchoolID=$R{SCHOOL_ID};) <---

    ( $R{SCHOOL_ID} is the report parameter here)

  4. Dynamic results are generated.

Can this be done ? Any tutorials ?

Dreamer
  • 481
  • 1
  • 5
  • 16

1 Answers1

0

The query will be like this

  SELECT * 
  FROM Students 
  WHERE SchoolID=$P{SCHOOL_ID}

We $R{} for text field expression and $P{} for parameter. If you develop this query in iReport then just drag the parameter from list of parameters where you want to add in query.

To create a input control:-

1:- Open Query executor in iReport.

2:- Add new parameter -

Parameter Name:- SCHOOL_ID
Value expression:- Text(if it is string)
Default value expression :- "ID01" (if its a ftring use "")
Sharad
  • 3,562
  • 6
  • 37
  • 59