Passing input paramters dynamically to Quey in BIRT report

Hi All,
I have a requirement where I need to append the query dynamically based on the input parameters value.
I am trying the below method, but doesn't work

In DataSet open method

    testDataSet = MXReportDataSetProvider.create(this.getDataSource().getName(), this.getName());
    testDataSet.open();

    var sqlText = new String();

    sqlText = "  SELECT  id, status,job,site from workorder "

    + " where " + params["where"]
    + "siva"
    ;
maximoDataSet.setQuery(sqlText);

in beforeOpen method of Dataset I am trying replace the text siva **in the query dynamically based on input parameter, but it is giving error
**cannot call method 'replace of undefined"
. Please help me, how can I do it?

//beforeOpen code
sqlText = this.sqlText.replace("siva", "AND STATUS = " + params["site"]);

Thank you!!

Answers

  • wwilliamswwilliams Junior Member

    This is what I do
    maximoDataSet = MXReportDataSetProvider.create(this.getDataSource().getName(), this.getName()); maximoDataSet.open();
    var myWhere =""; "

    if(BirtStr.toUpper(params["etonum"].value)) { myWhere =" AND prl.etonum LIKE '"+ BirtStr.toUpper(params["etonum"].value) + "%'" }

    Then in the SQL statement I just add
    ``sqlText = "Select .............

    • " AND " + MXReportSqlFormat.createParamWhereClause("pr.siteid", params["site"].toUpperCase())
      + myWhere``

    I have also used this when I alias a Maximo table name
    var myWhere = params["where"].replace("matrectrans","m");

    I am not sure the **THIS **works correctly for the BIRT that Maximo supplies if you are using their class files, although I have never tried it

  • Thank you so much Wlliams, that is perfectly working fine :) :)

Sign In or Register to comment.