简体   繁体   English

在Pentaho报表设计器中使用参数生成SQL查询

[英]generate SQL query in Pentaho report designer with parameters

I created two parameters named id and task_name in Pentaho report designer. 我在Pentaho报表设计器中创建了两个名为idtask_name参数。 Display type of both of them are drop down. 两者的显示类型均下拉。 When I am trying to change the query based on the parameters I didn't get any data in the drop-down. 当我尝试根据参数更改查询时,下拉菜单中没有任何数据。 But the data of the drop-down display when I do not edit the query with parameters My query is 但是,当我不使用参数编辑查询时,将显示下拉列表的数据。

SELECT * 
FROM tbl_project_tasks 
WHERE id = ${id}

can anyone help? 有人可以帮忙吗?

In the parameter you'll find a field named Query . 在参数中,您将找到一个名为Query的字段。 This query should not be the main query mentioned above. 此查询不应是上面提到的主要查询。 You should create a new query in which you only select the id from your data base. 您应该创建一个新查询,在其中仅从数据库中选择ID Name it idparameter for example. 例如,将其命名idparameter It goes like this: 它是这样的:

SELECT id 
FROM tbl_project_tasks

Now in the parameter select idparameter in Query , id in Value and id in Display Name . 现在,在参数中,在Query中选择idparameter ,在Value中选择id ,在Display Name中选择id Make sure that the name of the parameter in Name is the same as the one in the ${} in the main query. 确保“名称”中的参数名称与主查询中$ {}中的参数相同。

Hope that was the answer for your question. 希望这是您的问题的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM