[英]Is possible write in xls file and open the file when executed using plsql developer?
I have a procedure to write a report in Xls file using utl_file
.我有一个使用
utl_file
在 Xls 文件中编写报告的过程。
This procedure works correctly but my question is: is it possible to open this file directly in Excel after executed?此过程正常运行,但我的问题是:执行后是否可以直接在 Excel 中打开此文件? I ask it because, when it's executing now, I must open the folder path then open Xls file.
我问它是因为,当它现在执行时,我必须打开文件夹路径,然后打开 Xls 文件。
My Edit Code:我的编辑代码:
create or replace procedure write_file_daily(emp_id in number,Start_date in date,End_date in date, Job_Name in varchar2 ) is
file_handle UTL_FILE.file_type;
begin
file_handle := utl_file.fopen('CSV_DIR', 'REP.xls', 'W');
utl_file.put_line(file_handle, 'id'|| CHR(9) || 'name' || CHR(9) || 'department' || CHR(9) || 'unit' || CHR(9) || 'position' || CHR(9) || 'job'
);
for rws in (
select ID,
NAME,
DEPARTMENT,
UNIT,
POSITION,
JOB
from (select t.ID1 as ID,
t.NAME as Name,
(select d.divname from compdivs d where d.divid = t.COMP_id2) as DEPARTMENT,
decode((select d.parent1name from compdivs d where d.divid = t.COMP),
'XXX',
(select d.divname from compdivs d where d.divid = t.COMP),
(select d.parent1name from compdivs d where d.divid = t.COMP)) as UNIT,
(select d.dname from const_dt d where d.mid = 3 and d.no = t.WORKK) as Position,
(select d.dname from const_dt d where d.mid = 8 and d.no = t.EDUCATION_ID) as Job,
from th1 t
)
WHERE ( ID = emp_id or emp_id = -1)
and (Day_date between Start_date and End_date )
and( NVL(lower(JOB),' ') like NVL(lower('%'|| Job_Name ||'%'),NVL(lower(JOB),' ')))
)
loop
utl_file.put_line(file_handle, rws.id || CHR(9) || rws.name || CHR(9) || rws.department || CHR(9) || rws.unit || CHR(9) || rws.position || CHR(9) || rws.job
);
end loop;
utl_file.fclose(file_handle);
end write_file_daily;
Looks to me you want a feature of launching external program (MS Excel in your case) from within PLSQL Developer, triggered by SQL/PLSQL script execution, ideally with script result as input parameter.在我看来,您想要从 PLSQL Developer 中启动外部程序(在您的情况下为 MS Excel)的功能,由 SQL/PLSQL 脚本执行触发,最好使用脚本结果作为输入参数。 I can imagine it would be cool and did some exploration this way in the past, though, unfortunately PLSQL Developer seems not to provide any such feature.
我可以想象它会很酷,并且过去以这种方式进行了一些探索,但不幸的是 PLSQL Developer 似乎没有提供任何此类功能。
(Note I mean client machine, not db server. At db server side, there are some ways to invoke operating system command but I expect it does not apply to your case because your db server is probably different from your client machine.) (注意我的意思是客户端机器,而不是数据库服务器。在数据库服务器端,有一些方法可以调用操作系统命令,但我希望它不适用于您的情况,因为您的数据库服务器可能与您的客户端机器不同。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.