BIRT 4.4.0参数在运行时四舍五入 [英] BIRT 4.4.0 PARAMETERS getting rounded at runtime

查看:67
本文介绍了BIRT 4.4.0参数在运行时四舍五入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有BIRT 4.4.0报告,其报告参数为十进制数据类型. 在数据集预览结果"中(以及在运行报告时,report参数会向上/向下舍入到最接近的10),但我们已将问题缩小到数据集". 例如.如果参数是 0-4,向下舍入为0 5-9,四舍五入到10 10-14舍入到10 15到20轮舍入到20 : : 90-94向下舍入到90 95-100舍入为100

We have BIRT 4.4.0 report with a report parameter of decimal data type. The report parameter gets rounded up/down to the nearest 10 in Data Set Preview Results (and when the report is run, but we've narrowed the problem to the Data Set). E.g. if the paramter is 0-4, rounds down to 0 5-9, rounds up to 10 10-14 rounds down to 10 15-20 rounds up to 20 : : 90-94 rounds down to 90 95-100 rounds up to 100

该数据库是SQLServer2012.该问题尚未针对其他数据库进行测试.

The database is SQLServer 2012. The problem has not been tested against other databases.

.rptdesign不包括在内,因为下面的各种测试都会更改它,因此您可以使用空白报告. 问题出在数据集中,您无需运行报告,而只需预览数据集中的结果即可.

The .rptdesign is not being included, since the various tests below change it and you can use a blank report. The problem is in the DataSet and you won't need to run a report, but to preview results in the DataSet.

复制步骤 1)使用BIRT 4.4.0设计器,Java 1.7 u25(jdk-7u25-windows-i586.exe),SQLServer 2012

Steps to reproduce 1) Use BIRT 4.4.0 designer, Java 1.7 u25 (jdk-7u25-windows-i586.exe), SQLServer 2012

2)

Create a database (AlbumsDB) with a table (Albums) with the following columns
Title   varchar(50)  not null
Cost    decimal(18,0) not null
Type    char(10) not null

3)

Populate with the following 3 rows
   Title         Cost          Type
   APPLE          0               D
   ABBEY ROAD     1               D
   BEATLES        2               D

4)创建一个空白报告 5)创建SQLServer的数据源 6)创建一个数据集

4) Create a blank report 5) Create a Datasource to the SQLServer 6) Create a Dataset

BIRT中的数据集查询是使用从表中选择列(而不是键入)创建的. 请仅使用光标定位并双击列/表名称将其选中,以保持显示的格式完全相同.

The Data Set query in BIRT is created using column selection from the table (and not typed in). Please keep the format exactly as shown, using only cursor positioning and double-clicking the column/table names to select them.

select dbo.Albums.Title,
dbo.Albums.Cost,
dbo.Albums.type
from dbo.Albums
where dbo.Albums.Cost = ?

查询参数:

Name: param_1
Native Name: greyed out and not enterable
Data Type: Decimal
Direction: Input
Default Value: 2
Linked to Report Parameter: None

默认参数设置为2,因此测试将生成正确的Cost = 2行,或者向下舍入并生成错误的Cost = 0行.

The default parameter was set to 2, so that tests will either produce the correct Cost=2 row, or round down and produce the incorrect Cost=0 row.

1)以这种格式设置SQL语句时, -数据集中的预览结果"产生了错误的结果(四舍五入的Cost = 0行) -.rptdesign文件没有nativeDataType属性

1) When the SQL statement was setup in this format, - the "Preview Results' in the Data Set produced the wrong result (the rounded down Cost=0 row) - the .rptdesign file did not have the nativeDataType attribute

2)编辑sql并将表名调到与选择为最后一列的行相同的行上:

2) When sql was edited and the table name was brought up to the same line as the last column selected as:

select dbo.Albums.Title,
dbo.Albums.Cost,
dbo.Albums.type from dbo.Albums
where dbo.Albums.Cost = ?

  • 数据集中的"Peview结果"产生了正确的结果(Cost = 2行)
  • .rptdesign文件没有nativeDataType属性
  • 3)sql的格式为

    select dbo.Albums.Title, dbo.Albums.Cost,
    dbo.Albums.type 
    from dbo.Albums
    where dbo.Albums.Cost = ?
    

    select dbo.Albums.Title,.Albums.Cost,.Albums.type 
    from dbo.Albums
    where dbo.Albums.Cost = ?
    

    ,即,选定的某些或所有列与选择"放在同一行,而将从"保留在另一行 -数据集中的预览结果"产生了错误的结果(四舍五入的Cost = 0行) -.rptdesign文件没有nativeDataType属性

    that is, some or all columns selected put on same line as "select", keeping "from " on a separate line - the "Preview Results' in the Data Set produced the wrong result (the rounded down Cost=0 row) - the .rptdesign file did not have the nativeDataType attribute

    4)当整个SQL放在一行上时

    4) When the entire SQL was put on one line

    select dbo.Albums.Title,.Albums.Cost,.Albums.type from dbo.Albums where dbo.Albums.Cost = ?
    - the "Peview Results " in the Data Set produced the correct result  (the Cost=2 row)
    - the .rptdesign file now had the correct  nativeDataType attribute `<propert name="nativeDataType">3</property>`
    

    5)在语句中引入任何空格()时:

    5) When any whitespace (spaces) was introduced in the statement:

    select                dbo.Albums.Title,
    dbo.Albums.Cost,
    dbo.Albums.type
    from dbo.Albums
    where dbo.Albums.Cost = ?
    - the "Preview Results' in the Data Set produced the wrong result  (the rounded down Cost=0 row)
    - the .rptdesign file had an incorrect nativeDataType attribute `<property name="nativeDataType">0</property>`
    

    在上述所有测试中,如果还原了SQL格式,则nativeDataType属性将保留在.rptdesign文件中. 当"from dbo.Albums"被调到与"select"相同的行时,它从"0"变为"3".

    In all tests above, if the SQL format was reverted, the nativeDataType attribute stayed in the .rptdesign file. It got changed from "0" to "3" when the "from dbo.Albums" was brought upto the same line as "select".

    6)将nativeDataType行添加到.rptdesign无效,直到步骤6d) a)编辑初始.rptdesign(无nativeDataType)并使用在#1中创建的sql格式,并添加<property name="nativeDataType">3</property> -数据集中的预览结果"产生了错误的结果(四舍五入的Cost = 0行) b)然后添加<property name="nativeName"></property> -数据集中的预览结果"产生了错误的结果(四舍五入的Cost = 0行)

    6) Adding the nativeDataType line to the .rptdesign had no effect, until step 6d) a) Edited the initial .rptdesign (without the nativeDataType) and with the sql format as created in #1, and added <property name="nativeDataType">3</property> - the "Preview Results' in the Data Set produced the wrong result (the rounded down Cost=0 row) b) Then added <property name="nativeName"></property> - the "Preview Results' in the Data Set produced the wrong result (the rounded down Cost=0 row)

    c)然后添加<property name="isOptional">false</property> -数据集中的预览结果"产生了错误的结果(四舍五入的Cost = 0行)

    c) Then added <property name="isOptional">false</property> - the "Preview Results' in the Data Set produced the wrong result (the rounded down Cost=0 row)

    d)如果对SQL语句的格式进行了微小的更改(将从db.Albums"带到所选的最后一列的行),则CDReport.rptdesign会产生正确的结果.

    d) When a slight change to the format of the SQL statement is made (bring the "from db.Albums" up to the line of the last column selected), CDReport.rptdesign produces the correct result.

    推荐答案

    如d中所述,如果结果取决于SQL语句的格式(尽管语句的语义相同,则结果不同)无论是在BIRT 4.4.1中还是在JDBC驱动程序中(或在SQL Server中,但我都不这么认为),绝对是一个错误.

    If the results is depending on the SQL statements's format (different results although the semantics of the statements are the same), as you mention in d), then this is definitely a bug, either in BIRT 4.4.1 or in the JDBC driver (or in SQL Server, but I don't think so).

    要查看错误的实际发生位置,您应该

    To see where the bug is actually happening you should

    • 使用BIRT 4.2.1测试相同的报告

    • Test the same report with BIRT 4.2.1

    在某些SQL-JDBC IDE中测试SQL语句(使用bind vars完全相同的语句!)(对于Oracle,这将是SQL Developer,我不知道是否有类似的东西可用于MS SQL服务器)或缺少此类IDE的独立Java程序中.

    Test the SQL statement (exactly the same statement, using bind vars!) in some SQL-JDBC IDE (for Oracle, this would be SQL Developer, I don't know if something similar is available for MS SQL Server) or, lacking such an IDE, in a stand-alone Java program.

    使用不同的JDBC驱动程序测试相同的报告

    Test the same report with a different JDBC driver

    这篇关于BIRT 4.4.0参数在运行时四舍五入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆