Solved

ORA-29285 File Write error

Posted on 2009-07-13
6
3,638 Views
Last Modified: 2012-08-14
I am writing a stored procedure that writes to a file. Code pertaining to utl_file -

v_feed_out               UTL_FILE.FILE_TYPE;

BEGIN
  IF UTL_FILE.IS_OPEN (v_feed_out)
    THEN UTL_FILE.FCLOSE (v_feed_out);
  END IF;
 v_feed_out := utl_file.fopen('FAMIS_OUTPUT_DIR', 'ABC','w');


  OPEN ref_cursor for 'select * from ' || v_tbl_tmp;
  LOOP
       FETCH ref_cursor INTO V_DTL_REC.NAME,
                           V_DTL_REC.GENDER,
                           V_DTL_REC.STREET,
                           V_DTL_REC.CITY,
                           V_DTL_REC.STATE,
                           V_DTL_REC.ZIP,
                           V_DTL_REC.DOB,
                           V_DTL_REC.CLSSFCN,
                           V_DTL_REC.STATE_OF_ORIGIN,
                           V_DTL_REC.PHONE;
                           
                           
     
       V_DTL_REC.NAME := LPAD( V_DTL_REC.NAME, 120 );
       V_DTL_REC.STREET := LPAD( V_DTL_REC.STREET, 120 );
       V_DTL_REC.CITY := LPAD( V_DTL_REC.CITY, 25 );
       V_DTL_REC.STATE := LPAD( V_DTL_REC.STATE, 2 );
       V_DTL_REC.ZIP := LPAD( V_DTL_REC.ZIP, 10 );
       V_DTL_REC.STATE_OF_ORIGIN := LPAD( V_DTL_REC.STATE_OF_ORIGIN, 3 );
       V_DTL_REC.PHONE := LPAD( V_DTL_REC.PHONE, 10 );
       V_DTL_REC.UIN := LPAD( V_DTL_REC.UIN, 9 );
       
       V_OUTPUT_REC:=  V_DTL_REC.NAME ||
                       V_DTL_REC.STREET ||
                       V_DTL_REC.CITY ||
                       V_DTL_REC.STATE ||
                       V_DTL_REC.ZIP ||
                       V_DTL_REC.DOB ||
                       V_DTL_REC.CLSSFCN ||
                       V_DTL_REC.STATE_OF_ORIGIN ||
                       V_DTL_REC.PHONE ||
                       V_DTL_REC.UIN;
                     
       /*DBMS_OUTPUT.put_line( V_OUTPUT_REC ); */
       utl_file.put_line(v_feed_out, v_output_rec, TRUE);  
                           
       
   END LOOP;
   utl_file.fclose_all()
END;

When I am debugging, I see that atleast six rows have been processed and then I get a

ORA-29285: file write error
ORA-06512: at "SYS.UTL_FILE", line 171
ORA-06512: at "SYS.UTL_FILE", line 1093
ORA-06512: at "SYS.UTL_FILE", line 821

The data which is being read looks good to me. I dont know what I am missing. The output file is being created, but not all rows that have been looped through were written into the file.

Thanks

 

 
0
Comment
Question by:happylife1234
  • 4
  • 2
6 Comments
 
LVL 47

Expert Comment

by:schwertner
ID: 24840177
The directory  'FAMIS_OUTPUT_DIR' should be defined correctly
1. It should exist as logical directory,
2. The user should given write access to it
3. The underlying physical directory should exist
4. The oracle OS user should have permissions to write there.
0
 

Author Comment

by:happylife1234
ID: 24840216
The directory is set properly. Both logical and physical and The output file has been created with few rows written to it.
0
 
LVL 47

Accepted Solution

by:
schwertner earned 250 total points
ID: 24840282
Disk is full.
Some of the columns is a LOB
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 47

Expert Comment

by:schwertner
ID: 24840343
Also if the file exists you shoul use 'append' mode
0
 

Author Comment

by:happylife1234
ID: 24840591
I want to overwrite the same file everythime I run this stored procedure. And the disk is not full since I am able to run another store procedure that can write to the same folder. None of the columns are LOB they are simple names and addresses columns.

I dont know what could be the problem then.
0
 
LVL 47

Expert Comment

by:schwertner
ID: 24841862
Remove the file first.

The FREMOVE procedure removes a file from the system.

FREMOVE(location VARCHAR2, filename VARCHAR2)
An exception is thrown if the file to be removed does not exist.

Parameters

location

Directory name, as stored in pg_catalog.edb_dir.dirname, of the directory containing the file to be removed.

filename

Name of the file to be removed.

Examples

The following removes file empfile.csv.

DECLARE
    v_directory     VARCHAR2(50) := 'empdir';
    v_filename      VARCHAR2(20) := 'empfile.csv';
BEGIN
    UTL_FILE.FREMOVE(v_directory,v_filename);
    DBMS_OUTPUT.PUT_LINE('Removed file: ' || v_filename);
    EXCEPTION
        WHEN OTHERS THEN
            DBMS_OUTPUT.PUT_LINE('SQLERRM: ' || SQLERRM);
            DBMS_OUTPUT.PUT_LINE('SQLCODE: ' || SQLCODE);
END;

Removed file: empfile.csv
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Migrating an SQL 2008 database to Oracle 12c 3 88
case statement in where clause 5 40
Best RAID for a BDD Oracle 4 61
grouping on time windows 6 42
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now