?
Solved

Problem while using UTL_FILE.PUT

Posted on 2003-02-20
2
Medium Priority
?
1,700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to recover a database from a user managed backup
Suggested Courses

800 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