Solved

ORA-29285 File Write error

Posted on 2009-07-13
6
3,572 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.

Join & Write a Comment

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

746 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

10 Experts available now in Live!

Get 1:1 Help Now