如何强制 BIRT 显示零值?
我在BIRT报告中遇到了一个情况。我创建的报告坚持将某些字段显示为空白而不是零。当字段实际上是不返回行的子选择时,就会出现这种情况。
例如,如果选择包括:
0 as p3,
那么 0 就可以正常显示。但是,如果选择有:
(select sum(other_field) from other_table where ...) as p3,
该字段显示为空白。
修改数据以使子选择存在的行会导致显示值,即使它们的结果值为零。
所以我认为 BIRT 以某种方式将返回零行的子选择视为 NULL(它也显示为空单元格)而不是零。有谁知道如何强制 BIRT 显示实际的 0 而不是空单元格?
如果有人需要发布特定于 DBMS 的答案,我正在使用 DB2/z v8,尽管基于其他供应商的建议也会受到赞赏。
I have a situation in BIRT reporting. A report I created is insisting on displaying some fields as blank rather than zero. The situation arises when the field is actually a sub-select that returns no rows.
So for example, if the select includes:
0 as p3,
then the 0 is displayed okay. If however, the select has:
(select sum(other_field) from other_table where ...) as p3,
the field is displaying blank.
Modifying the data so that rows exist for the sub-select results in a value being displayed, even if their resultant value is zero.
So I'm thinking that somehow BIRT is treating a sub-select returning zero rows as a NULL (which it also displays as an empty cell) rather than a zero. Does anyone have any idea how to coerce BIRT into displaying an actual 0 rather than an empty cell?
I'm using DB2/z v8 if anyone needs to post a DBMS-specific answer, although even suggestions based on other vendors would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当列或表达式可能返回 NULL 时,尝试使用 COALESCE 函数强制指定一个值。
Try using the COALESCE function to force a value when a column or expression might return NULL.
另一种方法,虽然不那么优雅,但有时是必要的(例如,如果您正在执行您无法更改的存储过程),那就是使用JavaScript在运行时强制显示“0”。
使用以下表达式进行数据绑定:
根据数据类型,您可能需要向零添加引号
以表示字符串,如果没有引号,则将其视为整数。
Another way, although not as elegant but sometimes necessary (e.g. if your are executing a stored procedue that you cannot change), would be to use JavaScript to force the display of "0" at run time.
Use the following expression for your data binding:
Depending on the data type you might need to add quotes to the zero
to represent Strings, without quotes it is treated as an Integer.
在使用十进制数据时,我能够快速对该字段进行 +0 作为缩短版本。
While using decimal data I was able to do a quick +0 to the field as a shortened version.