ORACLE APEX 5.1.1:基于 PL/SQL 函数的图表在错误的标签中显示值
ORACLE APEX 5.1.1: Chart based on PL/SQL Function shows values in wrong label
我正在使用 ORACLE APEX 5.1.1 并希望显示基于 "PL/SQL Function Body returning SQL Query" 的图表。该函数根据 Select 列表的值更改 SQL-Query。因此,只要 Select 列表发生变化,图表就会发生变化。我已经设置了所有需要的查询和动态操作,功能运行良好。但图表显示错误的值 "Label slots"(x 轴上的类别)。为了澄清错误的图表显示,我还基于完全相同的函数创建了一个经典报告,它正确显示了值。
我在 https://apex.oracle.com 上的评估帐户上复制了一个最小示例。那里的一切都是它应该的样子。 apex.oracle.com 当前版本为 5.1.3。所以我想知道这是否是 5.1.1 版中已修复的错误。不过,我在发行说明中找不到有关此问题的任何信息。 有谁知道这个错误或可以帮助我解决 5.1.1 中的问题吗?不幸的是,我现在无法在公司环境中升级到 5.1.3。
这是我用于经典报告和图表的PL/SQL:
declare
q varchar2(32767);
begin
q :=
'
select
type1, type2, sum(to_number(val)) as val
from (
SELECT ''a'' as type1, ''x'' as type2, ''1'' as val
FROM DUAL
UNION ALL
SELECT ''a'' as type1, ''y'' as type2, ''2'' as val
FROM DUAL
UNION ALL
SELECT ''a'' as type1, ''z'' as type2, ''3'' as val
FROM DUAL
UNION ALL
SELECT ''b'' as type1, ''x'' as type2, ''3'' as val
FROM DUAL
UNION ALL
SELECT ''b'' as type1, ''z'' as type2, ''3'' as val
FROM DUAL
UNION ALL
SELECT ''c'' as type1, ''x'' as type2, ''2'' as val
FROM DUAL
UNION ALL
SELECT ''c'' as type1, ''y'' as type2, ''-2'' as val
FROM DUAL
UNION ALL
SELECT ''d'' as type1, ''y'' as type2, ''-3'' as val
FROM DUAL
UNION ALL
SELECT ''d'' as type1, ''z'' as type2, ''1'' as val
FROM DUAL
UNION ALL
SELECT ''e'' as type1, ''x'' as type2, ''1'' as val
FROM DUAL
UNION ALL
SELECT ''a'' as type1, ''z'' as type2, ''3'' as val
FROM DUAL
)
'
;
if :TEST_VALS = 'only positive' then q := q || ' where val >= 0';
elsif :TEST_VALS = 'only negative' then q := q || ' where val <= 0';
end if;
q := q || ' group by type1, type2 order by type1, type2';
return q;
end;
:TEST_VALS
指的是具有值 all, only positive, only negative
的静态 Select 列表。动态操作在 Select 列表中设置为更改时刷新,在经典报告和图表中设置为 "Page Items to Submit"。
下面有 3 个屏幕截图显示了 5.1.1 中的错误以及 5.1.3 中的正确图表显示。
5.1.1 的错误图表和选择 "all":
错误的图表 5.1.1 和选择 "only positive values":
使用 5.1.3 的正确图表(在网络评估帐户上):
最终,我自己在这里找到了答案:https://community.oracle.com/thread/4069783
问题与PL/SQL函数无关。在 ORACLE APEX 版本 5.1.3 之前,任何图表都要求每个系列中存在相同数量的数据点。因此,您需要自己在查询中添加数据致密化。我同意 ORACLE 开发人员的以下引述,即这不是最佳的...
For 5.1, we intentionally left the 'densification' of the data to the
customer to handle via their SQL query. However, this has led to some
confusion and numerous questions on the forum and at conferences, so
we have revised that behaviour for our upcoming 5.1.3 patch set
release. In that release, we will now automatically handle the
injection of missing data points, to ensure that the resulting JSON
object meets JET's requirement of having the same number of data
points, in each series of a multi-series chart, for each x-axis label.
I can't provide details of when 5.1.3 will be made available, so for
now you can manage the densification in your query.
我正在使用 ORACLE APEX 5.1.1 并希望显示基于 "PL/SQL Function Body returning SQL Query" 的图表。该函数根据 Select 列表的值更改 SQL-Query。因此,只要 Select 列表发生变化,图表就会发生变化。我已经设置了所有需要的查询和动态操作,功能运行良好。但图表显示错误的值 "Label slots"(x 轴上的类别)。为了澄清错误的图表显示,我还基于完全相同的函数创建了一个经典报告,它正确显示了值。
我在 https://apex.oracle.com 上的评估帐户上复制了一个最小示例。那里的一切都是它应该的样子。 apex.oracle.com 当前版本为 5.1.3。所以我想知道这是否是 5.1.1 版中已修复的错误。不过,我在发行说明中找不到有关此问题的任何信息。 有谁知道这个错误或可以帮助我解决 5.1.1 中的问题吗?不幸的是,我现在无法在公司环境中升级到 5.1.3。
这是我用于经典报告和图表的PL/SQL:
declare
q varchar2(32767);
begin
q :=
'
select
type1, type2, sum(to_number(val)) as val
from (
SELECT ''a'' as type1, ''x'' as type2, ''1'' as val
FROM DUAL
UNION ALL
SELECT ''a'' as type1, ''y'' as type2, ''2'' as val
FROM DUAL
UNION ALL
SELECT ''a'' as type1, ''z'' as type2, ''3'' as val
FROM DUAL
UNION ALL
SELECT ''b'' as type1, ''x'' as type2, ''3'' as val
FROM DUAL
UNION ALL
SELECT ''b'' as type1, ''z'' as type2, ''3'' as val
FROM DUAL
UNION ALL
SELECT ''c'' as type1, ''x'' as type2, ''2'' as val
FROM DUAL
UNION ALL
SELECT ''c'' as type1, ''y'' as type2, ''-2'' as val
FROM DUAL
UNION ALL
SELECT ''d'' as type1, ''y'' as type2, ''-3'' as val
FROM DUAL
UNION ALL
SELECT ''d'' as type1, ''z'' as type2, ''1'' as val
FROM DUAL
UNION ALL
SELECT ''e'' as type1, ''x'' as type2, ''1'' as val
FROM DUAL
UNION ALL
SELECT ''a'' as type1, ''z'' as type2, ''3'' as val
FROM DUAL
)
'
;
if :TEST_VALS = 'only positive' then q := q || ' where val >= 0';
elsif :TEST_VALS = 'only negative' then q := q || ' where val <= 0';
end if;
q := q || ' group by type1, type2 order by type1, type2';
return q;
end;
:TEST_VALS
指的是具有值 all, only positive, only negative
的静态 Select 列表。动态操作在 Select 列表中设置为更改时刷新,在经典报告和图表中设置为 "Page Items to Submit"。
下面有 3 个屏幕截图显示了 5.1.1 中的错误以及 5.1.3 中的正确图表显示。
5.1.1 的错误图表和选择 "all":
错误的图表 5.1.1 和选择 "only positive values":
使用 5.1.3 的正确图表(在网络评估帐户上):
最终,我自己在这里找到了答案:https://community.oracle.com/thread/4069783
问题与PL/SQL函数无关。在 ORACLE APEX 版本 5.1.3 之前,任何图表都要求每个系列中存在相同数量的数据点。因此,您需要自己在查询中添加数据致密化。我同意 ORACLE 开发人员的以下引述,即这不是最佳的...
For 5.1, we intentionally left the 'densification' of the data to the customer to handle via their SQL query. However, this has led to some confusion and numerous questions on the forum and at conferences, so we have revised that behaviour for our upcoming 5.1.3 patch set release. In that release, we will now automatically handle the injection of missing data points, to ensure that the resulting JSON object meets JET's requirement of having the same number of data points, in each series of a multi-series chart, for each x-axis label. I can't provide details of when 5.1.3 will be made available, so for now you can manage the densification in your query.