在IR报告中创建超链接

时间:2019-10-31 13:29:21

标签: oracle oracle11g oracle-apex oracle-apex-5.1

如何在oracle apex中将表中的信息从交互式报表列链接到其他外部页面?

要链接到的页面将显示不同的数据,具体取决于用户单击的IP。

我知道超链接使用href,但是oracle apex使用链接,但是没有任何作用

正在做的事的例子是

当用户单击IP地址时,我有一份IR报告,其中一列具有IP地址

假定将它们发送到我们服务器上的其他位置。

 100.100.100.100- should send me to the Printers

 100.100.100.101 -should send me to Drivers

1 个答案:

答案 0 :(得分:1)

这就是我对这个问题的理解。

  • TEST CTE代表您的表
  • 其中一列是“ ip_address”
  • 根据该值,您想要导航到某个URL

一种选择是使用CASE(或DECODE,但是-CASE更易于阅读和维护),并根据每个对象明确决定要去哪里ip_address的价值-这就是我的示例所显示的内容。

另一种方法是展开表(alter table ...),添加另一列,然后在其中放置确切的URL。这样可以更好地扩展,因为-如果您要在该表中添加新行,则必须编辑交互式报表的查询,并添加另一个CASE选项,即 stupid 。我建议你改变表。

无论如何,这是一个交互式报表查询。没什么特别的,只需注意编辑link列的属性并将“转义特殊字符”设置为“否”。

with test (id, name, ip_address) as
  (select 1, 'Google', '100.100.100.100' from dual union all
   select 2, 'Bing'  , '100.100.100.101' from dual
  )
select 
  id, 
  name,
  '<a href="' || case 
                  when ip_address = '100.100.100.100' then 'https://www.google.com'
                  when ip_address = '100.100.100.101' then 'https://www.bing.com'
                end
              || '" target="_blank">' || ip_address || '</a>' as link
from test;              

[编辑]

如果表本身包含URL,那么我建议使用类似的东西:

with test (id, name, ip_address, url) as
  (select 1, 'Google', '100.100.100.100', 'https://www.google.com' from dual union all
   select 2, 'Bing'  , '100.100.100.101', 'https://www.bing.com'   from dual
  )
select 
  id, 
  '<a href="' || url || '" target="_blank">' || name || '</a>' as link
from test;              

此查询将显示name作为超链接。为什么?因为我认为看到比起例如,「Go​​ogle」更容易接受“ 100.100.100.101”。人们通常更喜欢名称而不是数字。看看是否有帮助。