Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

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

如果SQL语句的结果太大,通过plsql developer无法显示所有的结果,这个时候,我们可以通过一段代码来完成,下面是一个例子:把select last_name, salary, department_idfrom employeesorder by department_id的结果显示到excel下面是具体例子:create or replace procedure out_excel(dir in varchar2,filename in varchar2) isfile utl_file.file_type;cursor empc isselect last_name, salary, department_idfrom employeesorder by department_id;beginfile := 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 LOOPUTL_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);EXCEPTIONWHENUTL_FILE.INVALID_FILEHANDLE THENRAISE_APPLICATION_ERROR(-20001, ‘Invalid File.’);WHEN UTL_FILE.WRITE_ERROR THENRAISE_APPLICATION_ERROR(-20002, ‘Unable to write to file’);whenutl_file.invalid_operation thenRAISE_APPLICATION_ERROR(-20003, ‘file operate invalid’);END out_excel;execute sal_status(dir =>’DIR_FILE’,filename => ‘outExcel.xls’);

温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
未整理

零基础学无人机航拍教程视频,换个角度看世界

2021-9-30 0:00:00

未整理

智睿政府网站管理系统 v10.1.4

2021-10-2 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索