Oracle APEX-使用按钮将查询导出到CSV [英] Oracle APEX - Export a query into CSV using a button

查看:255
本文介绍了Oracle APEX-使用按钮将查询导出到CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在顶点页面上有一个按钮,该按钮应允许用户将数据(基于最终用户看不到的查询)导出到CSV文件中.

I have a button on an apex page that should allow the user to export data (based on a query not seen by the end user) into a CSV file.

如何将此按钮链接到我的查询,以便我们可以将结果导出到CSV文件?

How to link this button to my query so we can export the result into a CSV file?

谢谢

推荐答案

感谢Scott Spendolini,我使用他的链接:

Thanks to Scott Spendolini, I use his link: https://spendolini.blogspot.fr/2006/04/custom-export-to-csv.html

我只是使用查询创建了一个报告区域.添加一个按钮,将您带到我创建的空白页面.在该页面上,我添加了一个PL/SQL流程,该流程将触发"加载时-标题之前".在该流程的源代码中,我使用以下代码:

I simply create a Report Region with my query. Add a button which will get you to a blank page that I created. On that page, I added a PL/SQL process which will fire "On Load - Before Header" In the source of that process, I use this code:

begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="emp.csv"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in EMP
for x in (select e.ename, e.empno, d.dname
from emp e, dept d where e.deptno = d.deptno
  and e.deptno like :P1_DEPTNO)
loop
 -- Print out a portion of a row,
 -- separated by commas and ended by a CR
 htp.prn(x.ename ||','|| x.empno ||','||
         x.dname || chr(13));
end loop;
-- Send an error code so that the
-- rest of the HTML does not render
htmldb_application.g_unrecoverable_error := true;
end;

这篇关于Oracle APEX-使用按钮将查询导出到CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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