0

我使用 Ireport 4.5 创建了一个报告,但我认为报告运行速度非常慢,我认为这只是因为多个 UNION 和 JOINS。

我正在复制一个简单的查询以进行测试:-

   SELECT b.Project_Id,
       b.Project_Manager,
       b.project_title,
       b.Project_location,
       b.Project_Level,
      SUM(COALESCE(b.Project_Budget, 0)) Projected,
      SUM(COALESCE(c.Accounting, 0)) Actual
   FROM t_authorized_budget a, t_project_c b,t_project_allocation c
   WHERE a.Project_Id = b.Project_Id and b.project_id=c.`Key` 
        and a.Project_Id = c.`Key`
        and $X{IN,b.project_location,p_project_location}
        and $X{IN,b.project_manager,p_project_manager}
        and $X{IN,b.project_id,p_project_id};

所以我使用这个查询创建了一个过程 CALL GetAllcompo() 但没有

        $X{IN,b.project_location,p_project_location}
        and $X{IN,b.project_manager,p_project_manager}
        and $X{IN,b.project_id,p_project_id};

现在我试图在从 Ireport 调用时在程序中添加这些条件。我怎样才能做到这一点?

4

1 回答 1

0

您需要使用该程序吗?我通过添加另一个参数来做到这一点。首先,提示用户定义您使用的 WHERE 子句类型:

$P{PROJECT_PROMPT}

然后使用定义 WHERE 子句的默认表达式创建第二个参数 ($P{PROJECT_SQL_DEF}):

 $P{PROJECT_PROMPT} == 'SHORT' ? 
      " ' a.Project_Id = b.Project_Id 
      and b.project_id=c.Key 
      and a.Project_Id = c.Key '" : 

      " ' a.Project_Id = b.Project_Id and b.project_id=c.`Key` 
      and a.Project_Id = c.`Key`
      and $X{IN,b.project_location,p_project_location}
      and $X{IN,b.project_manager,p_project_manager}
      and $X{IN,b.project_id,p_project_id} ' " 

在您的查询中:

 SELECT b.Project_Id,
   b.Project_Manager,
   b.project_title,
   b.Project_location,
   b.Project_Level,
  SUM(COALESCE(b.Project_Budget, 0)) Projected,
  SUM(COALESCE(c.Accounting, 0)) Actual
FROM t_authorized_budget a, t_project_c b,t_project_allocation c
WHERE $P!{PROJECT_SQL_DEF}
于 2013-02-04T14:18:12.947 回答