插入交互式报告中的数据到表格中(基于两个表格)。

huangapple go评论52阅读模式
英文:

Insert into the table data from the interactive report (based on two tables)

问题

亲爱的,

我有一个基于两个表的交互式报表(初始和示意),其中有一个选择列表作为筛选器,可以动态刷新报表。

SQL查询:

select
co.SITE_NAME,
co.SUST_FORM,
sn.DC_VS_S12345,
co.COMMENTS,
co.FILE_NAME as COOMENT_FILE_NAME,
sn.FILE_NAME as NUMBERS_FILE_NAME
from COMMENTS co
join SITE_NUMBERS sn on co.SITE_NAME = sn.SITE_NAME
where co.FILE_NAME = :P4_COMMENTS and sn.FILE_NAME = :P4_NUMBERS;

我想要实现的是将这个“初始”交互式报表中的筛选数据插入最终的目标表(比如 - FINAL_SUMMARY)。

我尝试创建一个在点击按钮后将这些数据添加到表格的进程,但我不知道如何传递来自此报表的数据...

有人能解释一下如何将这些经过筛选的预览数据添加到目标表吗?

提前感谢!

英文:

Dears,

I have an interactive report (initial and illustrative) based on two tables, with a select lists as a filter, which dynamically refresh the report.

Report

SQL query:

select
co.SITE_NAME,
co.SUST_FORM,
sn.DC_VS_S12345,
co.COMMENTS,
co.FILE_NAME as COOMENT_FILE_NAME ,
sn.FILE_NAME as NUMBERS_FILE_NAME
from COMMENTS co
join SITE_NUMBERS sn on co.SITE_NAME = sn.SITE_NAME
where co.FILE_NAME = :P4_COMMENTS and sn.FILE_NAME = :P4_NUMBERS;

What I would like to achieve is to insert those filtered data from this 'initial' interactive report into the final, target table (let's say - FINAL_SUMMARY).

I have tried to create a process that after clicking on the button will add those data to the table, but I don't know how to pass the data from this report...

Could someone explain to me what would be the way to add this filtered, preview data to the target table?

Thanks in advance!

答案1

得分: 1

一种处理方法是使用API APEX_EXEC.OPEN_QUERY_CONTEXT。这将允许您打开一个带有 APEX 为该区域执行的确切查询的游标。我建议阅读这篇博客,它描述了如何在一个分面搜索区域中执行此操作,然而,您也可以在交互式报表中执行此操作。

在那篇博客中,使用了一个管道函数来为另一个组件重新运行相同的查询。对于您的解决方案,显然是不需要的 - 您只需要查询。

英文:

One way to handle this is to use the api APEX_EXEC.OPEN_QUERY_CONTEXT. This will allow you to open a cursor with the exact query that was executed by APEX for that region. I'd suggest reading this blog that describes how to do this for a facet search region, however, you can do this for an interactive report as well.

In that blog a pipelined function is used to re-run the same query for another component. For you solution that is not needed obviously - you just need the query.

答案2

得分: 1

开始
l_query := '选择
co.SITE_NAME,
co.SUST_FORM,
sn.DC_VS_S12345,
co.COMMENTS,
co.FILE_NAME as COOMENT_FILE_NAME ,
sn.FILE_NAME as NUMBERS_FILE_NAME
from COMMENTS co
join SITE_NUMBERS sn on co.SITE_NAME = sn.SITE_NAME
where co.FILE_NAME = '||:P4_COMMENTS||' and sn.FILE_NAME = '||:P4_NUMBERS||';';

APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
p_collection_name => 'YOUR_COLLECTION_NAME',
p_query => l_query,
p_generate_md5 => 'YES');
End;

在你的交互式报表中使用以下查询

SELECT C001 SITE_NAME, C002 SUST_FORM FROM APEX_COLLECTION WHERE COLLECTION_NAME = 'YOUR_COLLECTION_NAME;

https://docs.oracle.com/cd/E59726_01/doc.50/e39149/apex_collection.htm#AEAPI725

英文:
Begin
    l_query := 'select
					co.SITE_NAME,
					co.SUST_FORM,
					sn.DC_VS_S12345,
					co.COMMENTS,
					co.FILE_NAME as COOMENT_FILE_NAME ,
					sn.FILE_NAME as NUMBERS_FILE_NAME
					from COMMENTS co
					join SITE_NUMBERS sn on co.SITE_NAME = sn.SITE_NAME
					where co.FILE_NAME = '||:P4_COMMENTS||' and sn.FILE_NAME = '||:P4_NUMBERS||';';
	
	APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
        p_collection_name => 'YOUR_COLLECTION_NAME', 
        p_query => l_query,
        p_generate_md5 => 'YES');
End;

USE the below query in your interactive report

SELECT C001 SITE_NAME, C002 SUST_FORM FROM APEX_COLLECTION WHERE COLLECTION_NAME = 'YOUR_COLLECTION_NAME;

https://docs.oracle.com/cd/E59726_01/doc.50/e39149/apex_collection.htm#AEAPI725

答案3

得分: 0

创建一个额外的按钮(放在两个选择列表项右侧),我们称其为P4_BTN_INSERT;其操作将是"提交"。

创建一个进程,将数据插入目标表;设置进程的条件,使其在按下P4_BTN_INSERT按钮时触发(如果不设置条件,每当设置任何选择列表项的值时进程将触发,因为我猜想它也会提交页面,正如你说的报表正在自动刷新)。

进程本身很简单;基本上,你正在重用交互式报表的源查询:

insert into target_Table
  (site_name, sust_form, dc_vs_s12345, comments, cooment_File_name, numbers_file_name)
select
co.SITE_NAME,
co.SUST_FORM,
sn.DC_VS_S12345,
co.COMMENTS,
co.FILE_NAME as COOMENT_FILE_NAME ,
sn.FILE_NAME as NUMBERS_FILE_NAME
from COMMENTS co
join SITE_NUMBERS sn on co.SITE_NAME = sn.SITE_NAME
where co.FILE_NAME = :P4_COMMENTS and sn.FILE_NAME = :P4_NUMBERS;
英文:

Create additional button (right beside two select list items) (let's call it P4_BTN_INSERT); its action will be "Submit".

Create a process which will insert data into the target table; set process' condition so that it fires when P4_BTN_INSERT button is pressed (if you don't process will fire whenever you set any select list item's value because it - I presume - also submits the page as you said that report is being automatically refreshed).

Process itself is simple; basically, you're reusing interactive report's source query:

insert into target_Table
  (site_name, sust_form, dc_vs_s12345, comments, cooment_File_name, numbers_file_name)
select
co.SITE_NAME,
co.SUST_FORM,
sn.DC_VS_S12345,
co.COMMENTS,
co.FILE_NAME as COOMENT_FILE_NAME ,
sn.FILE_NAME as NUMBERS_FILE_NAME
from COMMENTS co
join SITE_NUMBERS sn on co.SITE_NAME = sn.SITE_NAME
where co.FILE_NAME = :P4_COMMENTS and sn.FILE_NAME = :P4_NUMBERS;

huangapple
  • 本文由 发表于 2023年6月16日 02:43:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76484636.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定