Birt mongodb param

后端 未结 1 1220
悲&欢浪女
悲&欢浪女 2021-01-27 01:07

I installed Birt 4.3 (latest) as Eclipse plugin. JDBC as data source works perfectly for me. I define a param in query. I can define a param in data set via Report Design and li

相关标签:
1条回答
  • 2021-01-27 01:29

    MongoDB expression syntax itself does not support parameters, thus the MongoDB ODA connector does not support data set parameters directly. You can use BIRT scripting to reference a BIRT report parameter and change the runtime value of the "Command expression" data set property.

    You can identify the system connection when you make a MongoDB data set using Eclipse. This is in the MongoDB Collection area of the data set dialog.

    Check http://www.eclipse.org/forums/index.php/t/628348/ for more information.

    EXAMPLE

    You can use script to set the query using a beforeOpen script in the dataset such as:

    this.queryText ='{ "findQueryExpr" : "{ pop: { $gte: 20000  } }" , "operationType" : "FIND" , "collectionName" : "zipcode" , "selectedFields" : [ "_id" , "city", "pop"]}'
    

    The fields and collection name need to match the pre-configured dataset.

    Replace the 20000 with your parameter value. For example, using a parameter named "Population" which takes an integer, you can update your query at run-time with the following script:

    this.queryText ='{ "findQueryExpr" : "{ pop: { $gte: '+params["Population"].value+'  } }" , "operationType" : "FIND" , "collectionName" : "zipcode" , "selectedFields" : [ "_id" , "city", "pop"]}'
    
    0 讨论(0)
提交回复
热议问题