`
wsql
  • 浏览: 11715230 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

why not use the following way to generate the CSV file?

 
阅读更多

SQL> create directory reports as '/export/home/oracle'
2 ;

Directory created.

SQL> grant read,write on directory reports to scott;

Grant succeeded.
SQL> create or replace procedure print_reports_simple is
2 cursor c_direct_reports is
3 select
4 empno,
5 ename,
6 job,
7 hiredate,
8 sal
9 from emp;
10 wfile_handle utl_file.file_type;
11 v_wstring varchar2 (100);
12 v_header varchar2(100);
13 v_file varchar2(100);
14 v_date varchar2(20);
15 begin
16 v_header :='empno'||chr(9)||'ename'||chr(9)||'job'||chr(9)||'hiredate'||chr(9)||'sal';
17 v_file := 'onzin.xls';
18 wfile_handle := utl_file.fopen ('REPORTS',v_file, 'W');
19 utl_file.put_line(wfile_handle,v_header);
20 for r in c_direct_reports loop
21 v_wstring := r.empno||chr(9)||r.ename||chr(9)||r.job||chr(9)||to_char(r.hiredate,'dd/mm/yyyy')||chr(9)||r.sal;
22 utl_file.put_line(wfile_handle,v_wstring);
23 end loop;
24 utl_file.fclose (wfile_handle);
25 end print_reports_simple;
26 /

Procedure created.

SQL> exec print_reports_simple

PL/SQL procedure successfully completed.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
$ ls -lrt
total 2309458
-rw-r--r-- 1 oracle dba 136 Jan 12 16:12 local.cshrc
-rw-r--r-- 1 oracle dba 157 Jan 12 16:12 local.login
-rw-r--r-- 1 oracle dba 174 Jan 12 16:12 local.profile
drwxr-xr-x 2 oracle dba 512 Jan 12 16:16 Documents
drwxr-xr-x 2 oracle dba 512 Jan 12 16:16 Desktop
drwx------ 3 oracle dba 512 Jan 12 16:28 config
-rw------- 1 oracle dba 1000000000 Jan 13 12:52 swapfile
-rw------- 1 oracle dba 179640416 Jan 13 16:35 core
-rw-r--r-- 1 oracle dba 2104784 Jan 13 17:33 WF.log
drwxrwx--- 3 oracle dba 512 Jan 13 18:10 OracleHomes
drwxrwx--- 7 oracle dba 512 Jan 13 18:15 oraInventory
-rw-r--r-- 1 oracle dba 52330 Jan 19 09:43 datacollect.sql
-rw-r--r-- 1 oracle dba 17547 Jan 19 09:44 owbcollect.txt
-rw-r--r-- 1 oracle dba 1379 Jan 23 12:25 sqlnet.log
-rw-r--r-- 1 oracle dba 515 Mar 16 17:20 onzin.xls
$ more onzin.xls
empno ename job hiredate sal
7369 SMITH CLERK 17/12/1980 800
7499 ALLEN SALESMAN 20/02/1981 1600
7521 WARD SALESMAN 22/02/1981 1250
7566 JONES MANAGER 02/04/1981 2975
7654 MARTIN SALESMAN 28/09/1981 1250
7698 BLAKE MANAGER 01/05/1981 2850
7782 CLARK MANAGER 09/06/1981 2450
7788 SCOTT ANALYST 19/04/1987 3000
7839 KING PRESIDENT 17/11/1981 5000
7844 TURNER SALESMAN 08/09/1981 1500
7876 ADAMS CLERK 23/05/1987 1100
7900 JAMES CLERK 03/12/1981 950
7902 FORD ANALYST 03/12/1981 3000
7934 MILLER CLERK 23/01/1982 1300

分享到:
评论

相关推荐

    checksum.ini

    OPPO A59s,刷机提示can not find checksum.ini file,Please use ChecksumGenerateTool to generate the Checksum,下载这个文档放在刷机包里面,注意适用oppo a59s。其他的包可能会引起不适,我也是找了好几天,...

    How to generate the complex data regularly by DB Query Analyzer

    Considering the complex of the data required by Ministry of Transport of P.R.C every period of ten days, I design the following algorithm to generate the data required.

    How to use SFTP

    You should ensure that the server's public keys are loaded by the client as described in How to use SFTP (with server validation - known hosts), or you may want to switch off server validation to get ...

    hash table spell checking

    Goals: This assignment is designed to reinforce the student's understanding of the use of hash tables as searchable containers. Outcomes: Students successfully completing this assignment would master...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    For example, if your header file uses the File class in ways that do not require access to the declaration of the File class, your header file can just forward declare class File; instead of having ...

    OutlookAttachView v2.73

    enough disk space to store the saved file. The drawback of this mode: You cannot sort the attachments according to the column you choose with /sort command-line option. * Version 2.30 o Added '...

    Describes a way to automatically generate an application bui

    Describes a way to automatically generate an application build number.(35KB)

    Generate File步骤1

    Generate File步骤Started : "Synthesize - XST".Running xst...Command Line: xst -int

    数据结构作业Hash表

    Goals: This assignment is designed to reinforce the student's understanding of the use of hash tables as searchable containers. Outcomes: Students successfully completing this assignment would master...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令... ln -s file1 file1.sln 创建软链接。可跨系统操作,冲破操作权限;也是快捷方式。 八、时间显示 date 显示时间,精确到秒 用法 date [-u] mmddHHMM[[cc]yy][.SS] date [-u] [+format] ...

    IBIS2SPICE

    The IBIS to SPICE application does not perform a complete validation of the IBIS file. Only that information which is necessary for the generation of a SPICE model is validated and extracted from the...

    微软内部资料-SQL性能优化2

    Reserving memory address space is a way to reserve a range of virtual addresses for later use. If you attempt to access a reserved address that has not yet been committed (backed by memory or disk) ...

    Java邮件开发Fundamentals of the JavaMail API

    To use the JavaMail 1.1.3 API, download the JavaMail 1.1.3 implementation, unbundle the javamail1_1_3.zip file, and add the mail.jar file to your CLASSPATH. The 1.1.3 implementation comes with an ...

    linqer_4.6.0.0_trial.exe

    Linqer is a SQL to LINQ ... Visual Studio needs to be installed, in order to use the SqlMetal tool to generate LINQ to SQL model files or the EdmGen tool to generate LINQ to Entities model files.

    Android代码-Micopi

    So if you do not happen to have a (decent) photo of them, you can use the app to simply generate one. Micopi does not use a random number generator to create these images. It exclusively uses contact...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    Added TFlexFileFormat.StreamSupport property (default True), which difines, is it necessary to open file stream or give the file name only. - FIX: If the TCustomProp.Assign method calls when the ...

    解决Could not generate DH keypair

    加密是报:javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair 此处提供 bcprov-ext-jdk15on-154.jar 和 bcprov-jdk15on-154.jar 压缩包中有使用说明

    BobBuilder_app

    I deferred from testing the get test over 100 million record as it would require a huge array in memory to store the Guid keys for finding later, that is why there is a NT (not tested) in the table. ...

    squashfs1.3r3.tar.gz

    the following 'appending to squashfs filesystems' subsection. SYNTAX:mksquashfs source1 source2 ... dest [options] [-e list of exclude dirs/files] Options are -info print files written to ...

    generate xml format file

    NULL 博文链接:https://wfzgsm.iteye.com/blog/2001012

Global site tag (gtag.js) - Google Analytics