plsql导入excel数据(plsql命令窗口导入sql文件)

来源:国外服务器 在您之前已被浏览:1 次
导读:目前正在解读《plsql导入excel数据(plsql命令窗口导入sql文件)》的相关信息,《plsql导入excel数据(plsql命令窗口导入sql文件)》是由用户自行发布的知识型内容!下面请观看由(国外主机 - www.2bp.net)用户发布《plsql导入excel数据(plsql命令窗口导入sql文件)》的详细说明。
笨笨网美国主机,w ww.2 b p .n e t

如果SQL语句的结果太大,通过plsql developer无法显示所有的结果,这个时候,我们可以通过一段代码来完成,下面是一个例子:

select last_name, salary, department_id
from employees
order by department_id
的结果显示到excel
下面是具体例子:
create or replace procedure out_excel(dir in varchar2,
filename in varchar2) is
file utl_file.file_type;
cursor empc is
select last_name, salary, department_id
from employees
order by department_id;
begin
file := utl_file.fopen(dir, filename, ‘w’);
utl_file.put_line(file, ‘report: generated on ‘ || sysdate);
utl_file.new_line(file);
utl_file.put_line(file,
‘department_id’ || chr(9) || ‘name’ || chr(9) ||
‘salary’);
FOR emp_rec IN empc LOOP
UTL_FILE.PUT_LINE(file,
nvl(emp_rec.department_id, ”) || chr(9) ||
emp_rec.last_name || chr(9) || emp_rec.salary);
END LOOP;
UTL_FILE.PUT_LINE(file, ‘*** END OF REPORT ***’);
UTL_FILE.FCLOSE(file);
EXCEPTION
WHEN
UTL_FILE.INVALID_FILEHANDLE THEN
RAISE_APPLICATION_ERROR(-20001, ‘Invalid File.’);
WHEN UTL_FILE.WRITE_ERROR THEN
RAISE_APPLICATION_ERROR(-20002, ‘Unable to write to file’);
when
utl_file.invalid_operation then
RAISE_APPLICATION_ERROR(-20003, ‘file operate invalid’);
END out_excel;
execute sal_status(dir =>’DIR_FILE’,filename => ‘outexcel.xls’);

笨笨网美国主机,w ww.2 b p .n e t
提醒:《plsql导入excel数据(plsql命令窗口导入sql文件)》最后刷新时间 2025-03-21 11:19:44,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《plsql导入excel数据(plsql命令窗口导入sql文件)》该内容的真实性请自行鉴别。