eclipsebirt

BIRT reporting - use the same parameter multiply times in a SQL query


I have this where clause:

WHERE p.ROLE = 'doctor'
AND((p6.PA_Name='Event_Day_From' AND p6.PA_Value>= SUBSTRING('01.01.2012', 1, 2))
AND (p7.PA_Name='Event_Month_From' AND p7.PA_Value>=SUBSTRING('01.01.2012', 4, 2))
AND (p8.PA_Name='Event_Year_From' AND P8.PA_Value>=SUBSTRING('01.01.2012', 7, 4)))
AND ((p9.PA_Name='Event_Day_To' AND P9.PA_Value<=SUBSTRING('30.12.2012', 1, 2))
AND (p10.PA_Name='Event_Month_To' AND P10.PA_Value<=SUBSTRING('30.12.2012', 4, 2))
AND (p11.PA_Name='Event_Year_To' AND P11.PA_Value<=SUBSTRING('30.12.2012', 7, 4)))

after the above I have an union all and at the end I have another WHERE clause exactly the same as the above.

In BIRT a parameter can be passed and you have to insert ? in the SQL query where you need it to be passed. As you can see I have a start date and an end date which will be passed through an user input. Now my problem is that I have no idea how to pass the SDate parameter to all the start dates and the EndDate parameter to all the end dates

Is there a solution for my problem?


Solution

  • I solved this problem by creating table with a single row from the parameters, and attaching it to the report query like so:

    ,(select ? SDate, ? EDate) params
    WHERE p.ROLE = 'doctor'
    AND((p6.PA_Name='Event_Day_From' AND p6.PA_Value>= SUBSTRING(params.SDate, 1, 2))
    AND (p7.PA_Name='Event_Month_From' AND p7.PA_Value>=SUBSTRING(params.SDate, 4, 2))
    AND (p8.PA_Name='Event_Year_From' AND P8.PA_Value>=SUBSTRING(params.SDate, 7, 4)))
    AND ((p9.PA_Name='Event_Day_To' AND P9.PA_Value<=SUBSTRING(params.EDate, 1, 2))
    AND (p10.PA_Name='Event_Month_To' AND P10.PA_Value<=SUBSTRING(params.EDate, 4, 2))
    AND (p11.PA_Name='Event_Year_To' AND P11.PA_Value<=SUBSTRING(params.EDate, 7, 4)))
    

    Hope this helps.

    **I use this method on a PostgreSQL database currently.