如何在BIRT中比较一个数据集中的两个数据行

发布于 2024-12-15 13:36:56 字数 62 浏览 3 评论 0原文

我是 BIRT 新手,需要回答以下问题: 如何在BIRT中比较一个数据集中的两个数据行,然后打印出来到文档中?

I'm new to BIRT and need an answer to the following question:
How to compare two data rows in one data set in BIRT and then print it out to the document?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

李白 2024-12-22 13:36:56

我假设您有理由不使用自连接查询来引入数据。您可以做的一件简单的事情是拥有 2 个相同的数据集,然后使用这 2 个数据集创建一个新的联合数据集。

I am assuming you have a reason for not using a self-join query to bring in the data. One simple thing you could do is have 2 identical datasets and then create a new joint dataset using the 2.

东北女汉子 2024-12-22 13:36:56

借助 Oracle DB,您可以使用“分析函数”LAG 通过纯 SQL 轻松实现此目的(有关详细信息,请参阅 Oracle 文档)。

独立于数据库,通过 BIRT,您可以使用变量 last_row:

创建一些计算列来保存比较结果。例如“FIRST_COLUMN_CHANGED”作为布尔值。

afterOpen 事件:

last_row = null;

onFetch 事件(请注意,我不确定实际数据列是从 0 还是 1 开始):

if (last_row != null) {
    if (last_row[0] == row[0]) {
        row["FIRST_COLUMN_CHANGED"] = false;
    } else {
        row["FIRST_COLUMN_CHANGED"] = true;
    }
} else {
    // do computations for the first record.
    row["FIRST_COLUMN_CHANGED"] = true;
}

// Copy the current row to last_row
last_row = {};
// modify depending on the number of columns
for (var i=0; i<10; i++) {
    last_row[i] = row[i];
}

With an Oracle DB, you could easily achieve this with pure SQL using the "Analytic Function" LAG (see the Oracle documentation for details).

Independent from the DB, with BIRT, you could use a variable last_row:

Create some computed columns to keep the results of your comparisons. e.g. "FIRST_COLUMN_CHANGED" as boolean.

afterOpen event:

last_row = null;

onFetch event (pls note I'm not sure wether the actual data columns start at 0 or 1):

if (last_row != null) {
    if (last_row[0] == row[0]) {
        row["FIRST_COLUMN_CHANGED"] = false;
    } else {
        row["FIRST_COLUMN_CHANGED"] = true;
    }
} else {
    // do computations for the first record.
    row["FIRST_COLUMN_CHANGED"] = true;
}

// Copy the current row to last_row
last_row = {};
// modify depending on the number of columns
for (var i=0; i<10; i++) {
    last_row[i] = row[i];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文