?
Solved

Problem while using UTL_FILE.PUT

Posted on 2003-02-20
2
Medium Priority
?
1,708 Views
Last Modified: 2007-12-19
Hi All,

I am writing to a file using UTL_FILE.PUT command. The header of the file is of 2600 chacters. Whenever I use the command, it gives me an error. Hence I tried to write after spliting the big string into 4 parts , but in any case it is giving me the same error.

I understand the maximum size for output record is 1023 bytes. It alls me to write on the next line (using UTL_FILE.PUT_LINE command).

But my requirement states that the header should be a single line since the file is later use for SQL import. Can anyone help me with this.? I do not want to have CRLF (Line feed) after 1023 characters? Is it possible to do so?

Thanks in advance,
Pankaj
0
Comment
Question by:Pankaj27
2 Comments
 

Accepted Solution

by:
clawed earned 200 total points
ID: 7992007
Yes, if you're using Oracle 8 or above.

In your UTL_FILE.FOPEN command, you need to add a parameter for maximum line size (max 32767). Then, just write the whole line.

PROCEDURE myproc IS
 outfile  UTL_FILE.FILE_TYPE;
 filename varchar2 := 'myfile.txt';
 file_directory varchar2 := '/ORACLE/outfiles';
 myline VARCHAR2(32767);
 cursor c is select something from somethingorother;  
 rec c%ROWTYPE;
BEGIN
outfile := UTL_FILE.FOPEN(file_directory,filename,'W',32767);
OPEN c;
LOOP
   FETCH c into rec;
   exit when c%notfound;
   myline := rec.something;

   UTL_FILE.PUT_LINE(outfile,myline);

END LOOP;
CLOSE c;
UTL_FILE.FCLOSE(outfile);
EXCEPTION
   WHEN OTHERS THEN
      dbms_output.put_line('We don''t need no steenking error messages');
END myproc;
0
 
LVL 1

Author Comment

by:Pankaj27
ID: 7997524
Clawed,

Thats a perfect solutions. ! Thanks

~Pankaj
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

616 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question