Home » SQL & PL/SQL » SQL & PL/SQL » File write error
File write error [message #318464] |
Tue, 06 May 2008 23:11  |
subbu_tce
Messages: 98 Registered: July 2007 Location: pune
|
Member |
|
|
Dear ,
CREATE OR REPLACE PROCEDURE process_report
AS
ft UTL_FILE.FILE_TYPE;
f VARCHAR2 (30) := 'MNJ' || TO_CHAR (SYSDATE, 'ddmmyyyy')|| '.csv';
BEGIN
ft := UTL_FILE.FOPEN ('UTL_PATH_C', f, 'w');
UTL_FILE.PUT_LINE
(ft,
'"Sno.","Emp Code","Name","Relation","Birth Date"'
);
FOR i IN 1 .. medicarelist.COUNT
LOOP
UTL_FILE.PUT_LINE (ft,
i
|| ','
|| medicarelist (i).med_comp_name
|| ','
|| medicarelist (i).relation_name
|| ','
|| medicarelist (i).relation
|| ','
|| medicarelist (i).birth_dt
|| ','
);
END LOOP;
UTL_FILE.FCLOSE (ft);
END;
In medicarelist data's will come more than 50,000.
When am executing this procedure am getting file write error.
Kindly suggest me.
|
|
|
|
|
|
Re: File write error [message #318491 is a reply to message #318483] |
Wed, 07 May 2008 00:50   |
rajatratewal
Messages: 507 Registered: March 2008 Location: INDIA
|
Senior Member |
|
|
Open SQL* Plus:-
SQL> select * from emp;
EMPNO ENAME JOB MGR SAL COMM DEPTNO
---------- ---------- --------- ---------- ---------- ---------- ----------
123 Bob 1 2 1 Sales 555 10000 14 11
321 Sue Finance 555 42000 12 33
234 Mary Account 555 33000 12 22
289 Test 1 Manager 555 45000 12 23
888 Bob 1 2 1 NOZOMI 555 10000 12 11
123 Bob 1 2 1 Sales 555 10000 12 11
6 rows selected.
SQL> spool c:\test.csv
SQL> select empno||','||ename||','||job||','||mgr||','||sal||','||comm||','||deptno from emp;
EMPNO||','||ENAME||','||JOB||','||MGR||','||SAL||','||COMM||','||DEPTNO
--------------------------------------------------------------------------------
123,Bob 1 2 1,Sales,555,10000,14,11
321,Sue,Finance,555,42000,12,33
234,Mary,Account,555,33000,12,22
289,Test 1,Manager,555,45000,12,23
888,Bob 1 2 1,NOZOMI,555,10000,12,11
123,Bob 1 2 1,Sales,555,10000,12,11
6 rows selected.
SQL> spool off;
Find Data in test.csv file in C:\directory.
|
|
|
|
Re: File write error [message #318512 is a reply to message #318491] |
Wed, 07 May 2008 01:29   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
@rajatratewal
From the forum guidelines:
Quote: | Responding to Posts
When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.
|
The OP could have easily found out how to use spool by using Frank's advice. Try not to spoon feed learners, you are not doing them any favours in the long run.
|
|
|
|
|
Goto Forum:
Current Time: Mon Feb 17 22:18:24 CST 2025
|