Problem in UTL_FILE

I have written a following procedure and it complies successfully.
create or replace procedure utl_file_test_write (
path in varchar2,
filename in varchar2,
firstline in varchar2,
secondline in varchar2)
is
output_file utl_file.file_type;
begin
output_file := utl_file.fopen (path,filename, 'W');
utl_file.put_line (output_file, firstline);
utl_file.put_line (output_file, secondline);
utl_file.fclose(output_file);
end;
I have create the directory using the following command
SQL> CREATE DIRECTORY log_dir AS 'd:\oracle\oraclelog_dir';
Directory created
SQL> GRANT READ ON DIRECTORY log_dir TO DBA;
Grant succeeded
SQL> CREATE DIRECTORY out_dir AS 'd:\oracle\oracleout_dir';
Directory created
SQL> GRANT READ ON DIRECTORY out_dir TO DBA;
Grant succeeded
SQL> COMMIT;
But when I execute this then it gives the following error.
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.UTL_FILE", line 98
ORA-06512: at "SYS.UTL_FILE", line 157
ORA-06512: at "UTL_FILE_TEST_WRITE", line 9
ORA-06512: at line 1
I am using the following version.
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
PL/SQL Release 8.1.5.0.0 - Production
CORE Version 8.1.3.0.0 - Production
TNS for Solaris: Version 8.1.5.0.0 - Production
NLSRTL Version 3.4.0.0.0 - Production
Can anybody help me how can I solve the problem.
Thanks in advance

I think you are not handeling the exceptions. First you add the exceptions and it will tell you what kind of exception is raised.
Try:
  EXCEPTION
       WHEN utl_file.invalid_path THEN
         raise_application_error(-20100,'Invalid Path');
       WHEN utl_file.invalid_mode THEN
         raise_application_error(-20101,'Invalid Mode');
       WHEN utl_file.invalid_operation THEN
         raise_application_error(-20102,'Invalid Operation');
       WHEN utl_file.invalid_filehandle THEN
         raise_application_error(-20103,'Invalid Filehandle');
       WHEN utl_file.write_error THEN
         raise_application_error(-20104, 'Write Error');
       WHEN utl_file.read_error THEN
         raise_application_error(-20105,'Read Error');
       WHEN utl_file.internal_error THEN
         raise_application_error(-20106,'Internal Error');
       WHEN others THEN
         utl_file.fclose(v_file_id);
         raise_application_error (-20007, sqlerrm);HTH
Ghulam

Similar Messages

  • Problem with UTL_FILE (please see my last post on this thread)

    Hi all,
    I'm trying to get the code (procedures, functions, etc) of my schemas. I've tried it using DBMS_METADATA.GET_DDL but it fails with many objects. Finally, I'm trying to create a procedure to extract the code.
    I've created this two procedures:
    CREATE OR REPLACE PROCEDURE spool_code (code IN varchar2, propi IN varchar2) is
    CURSOR codigo is
    select text from dba_source where name = code and owner = propi order by line;
    line varchar2(4000);
    BEGIN
    open codigo;
    loop
    fetch codigo into line;
    exit when codigo%notfound;
    dbms_output.put_line(line);
    end loop
    close;
    END;
    CREATE OR REPLACE PROCEDURE ext_codigo is
    CURSOR objeto is
    select object_name, owner from dba_objects where object_type in ('PROCEDURE','FUNCTION','PACKAGE')
    and owner not in ('OUTLN','DBSNMP','SYSTEM','SYS','REPADMIN','PERFSTAT','SPOTLIGHT','MONITOR','PRUEBAS','TOAD')
    and status='VALID';
    nom varchar2(128);
    owner varchar2(30);
    BEGIN
    open objeto;
    loop
    fetch objeto into nom, owner;
    exit when objeto%notfound;
    spool_code(nom, owner);
    end loop;
    close objeto;
    END;
    And I'm calling from sqlplus to spool it:
    SQL> spool Users_code.sql
    SQL> exec ext_codigo;
    But it don't bring me results...
    where is the problem??
    Thanks in advance for your support!
    dbajug
    Edited by: dbajug on Aug 29, 2012 6:36 AM

    Hi,
    yes guys, I've set serverout on using the max limit but, always fails with:
    ERROR at line 1:
    ORA-20000: ORU-10027: buffer overflow, limit of 1000000 bytes
    ORA-06512: at "SYS.DBMS_OUTPUT", line 35
    ORA-06512: at "SYS.DBMS_OUTPUT", line 198
    ORA-06512: at "SYS.DBMS_OUTPUT", line 139
    ORA-06512: at "SYS.SPOOL_CODE", line 15
    ORA-06512: at "SYS.EXT_CODIGO", line 17
    ORA-06512: at line 1
    I'm working with a 9i version trying to extract the code to migrate it to a 11g.
    In order to avoid the buffer error, I've decide use the UTL_FILE package but I'm having another problem: my procedure now is this
    CREATE OR REPLACE PROCEDURE spool_code (code IN varchar2, propi IN varchar2) is
    CURSOR codigo is
    select text from dba_source where name = code and owner = propi order by line;
    line varchar2(4000);
    out_file UTL_FILE.File_Type;
    BEGIN
    begin
    out_file := UTL_FILE.Fopen('/export/home/oracle', 'Users_code.sql', 'w');
    exception
    when others then
    dbms_output.put_line('Error opening file');
    end;
    open codigo;
    loop
    fetch codigo into line;
    exit when codigo%notfound;
    UTL_FILE.Put_Line(out_file, line);
    end loop;
    close codigo;
    UTL_FILE.Fclose(out_file);
    END;
    The directory exists and the file too but fails with this error:
    ERROR at line 1:
    **ORA-29282: invalid file ID**
    ORA-06512: at "SYS.UTL_FILE", line 714
    ORA-06512: at "SYS.SPOOL_CODE", line 23
    ORA-06512: at "SYS.EXT_CODIGO", line 17
    ORA-06512: at line 1
    any idea? about the reason? The file is a text file on the server:
    ls -lrt /export/home/oracle/Users_code.sql
    -rw-rw-r-- 1 oracle dba 0 Aug 29 14:43 /export/home/oracle/Users_code.sql
    best regards,
    dbajug

  • Problems with UTL_FILE.PUTF

    I have a problem that occurs ( sometimes ) when using utl_file.putf.
    It not writes anything to the file and Oracle doesn't raise any exception.
    I have debugged the program and checked all the variables and none of them has
    null value at the point when the values are written to the file.
    Here is the code:
    Procedure P4_PRINCIPAL (inCont_id_contrato in number,
    inNped_id_nota_pedido in number,
    icNped_id_ext_prov in char,
    icCont_nro_contrato in char
    IS
    lcNo_pedido char(15) default ''; -- Nro pedido SGOS-DDR
    lcId_pedido char(20) default ''; -- Id. pedido en SRC
    lcNo_protocolo char(20) default ''; -- Nro. Contrato en SGOS-DDR
    lnCads_id_cadastro_np number(15); -- Id de cadastro tabla cadastro
    lnCads_numero_os number(9); -- Numero de OS
    lcCads_numero_os char(9); -- Numero de OS
    ldCads_fecha_ingreso date; -- fecha cadastro
    lcCads_fecha_ingreso char(14); -- fecha cadastro
    lncads_cant_os number(5); -- cantidad total de OS para N/P
    lccads_cant_os char(5); -- cantidad total de OS
    ldDatafact date; -- Fecha Faturamento
    lcDatafact char(14); -- Fecha Faturamento
    lvespacios varchar2(32767);
    ESPACIOS_OS constant char(9) := '000000000'; -- Espacios ...
    contador_os number(9);
    ldTimestamp date; -- Fecha generacion del archivo
    lcTimestamp char(14); -- Fecha generacion del archivo
    archivo_escritura UTL_FILE.FILE_TYPE;
    archivo_escritura2 UTL_FILE.FILE_TYPE;
    lvFech_arch varchar2(6);
    lnSeq_arch number(4);
    lvNom_arch_salida_formato varchar(20);
    erroluis varchar2(4000);
    iorecError src_general.recError; -- var. registro de error
    BEGIN
    lcNo_pedido := icNped_id_ext_prov;
    lcId_pedido := inCont_id_contrato||'-'||to_char(inNped_id_nota_pedido);
    lcNo_protocolo := icCont_nro_contrato;
    BEGIN
    SELECT cads_numero_os, cads_fecha_ingreso
    INTO lncads_numero_os, ldcads_fecha_ingreso
    FROM (SELECT cads_numero_os, cads_fecha_ingreso
    FROM DDR_CADASTRO
    WHERE nped_id_nota_pedido = inNped_id_nota_pedido
    AND cont_id_contrato = inCont_id_contrato
    ORDER BY cads_numero_os)
    WHERE ROWNUM = 1;
    EXCEPTION
    when no_data_found then
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    WHEN OTHERS THEN
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    END;
    if length(lncads_numero_os) > 9 then
    lncads_numero_os:=substr(lncads_numero_os,1,9);
    end if;
    lccads_numero_os := lpad(to_char(lncads_numero_os),9,'0');
    lccads_fecha_ingreso := to_char(ldCads_fecha_ingreso,'YYYYMMDDHH24MISS');
    Begin
    select count(*) into lncads_cant_os
    from DDR_CADASTRO
    where nped_id_nota_pedido = inNped_id_nota_pedido
    and cont_id_contrato = inCont_id_contrato;
    Exception
    when no_data_found then
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    WHEN OTHERS THEN
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    End;
    lccads_cant_os := lpad(to_char(lncads_cant_os),5,'0');
         ldTimestamp := SYSDATE;
         lcTimestamp := to_char(ldTimestamp, 'YYYYMMDDHH24MISS');
    lvFech_arch:= to_char(sysdate,'YYMMDD');
    Begin
    SELECT src_seq_p4.nextval
    INTO lnSeq_arch
    FROM dual;
    Exception
    when no_data_found then
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    when others then
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    End;
    lvNom_arch_salida_formato:= 'P4_'||lvFech_arch||'_'||lpad(lnSeq_arch, 4, '0');
    Begin
    archivo_escritura := UTL_FILE.FOPEN(SRC_CONST_GRAL.DIRECT_ENT_SGDDR,lvNom_arch_salida_formato,'W',32767);
    archivo_escritura2 := UTL_FILE.FOPEN(SRC_CONST_GRAL.DIRECT_SAL_SGDDR,lvNom_arch_salida_formato,'W',32767);
    UTL_FILE.PUTF (archivo_escritura,'%s%s%s%s%s',lcNo_pedido, lcId_pedido, lcNo_protocolo, lcCads_fecha_ingreso||lcCads_cant_os||lccads_numero_os);
    UTL_FILE.PUTF (archivo_escritura2,'%s%s%s%s%s',lcNo_pedido, lcId_pedido, lcNo_protocolo, lcCads_fecha_ingreso||lcCads_cant_os||lccads_numero_os);
    SRC_REG_APISGOSDDR.P4_REGISTRO(lcNo_pedido, lcId_pedido, lcNo_protocolo, lcCads_cant_os, lccads_numero_os, lvNom_arch_salida_formato);
    UTL_FILE.FCLOSE(archivo_escritura);
    UTL_FILE.FCLOSE(archivo_escritura2);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    UTL_FILE.FCLOSE(archivo_escritura);
    UTL_FILE.FCLOSE(archivo_escritura2);
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    commit;
    WHEN UTL_FILE.INVALID_PATH THEN
    UTL_FILE.FCLOSE(archivo_escritura);
    UTL_FILE.FCLOSE(archivo_escritura2);
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    commit;
    WHEN UTL_FILE.READ_ERROR THEN
    UTL_FILE.FCLOSE(archivo_escritura);
    UTL_FILE.FCLOSE(archivo_escritura2);
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    commit;
    WHEN UTL_FILE.WRITE_ERROR THEN
    UTL_FILE.FCLOSE(archivo_escritura);
    UTL_FILE.FCLOSE(archivo_escritura2);
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    commit;
    WHEN OTHERS THEN
    UTL_FILE.FCLOSE(archivo_escritura);
    UTL_FILE.FCLOSE(archivo_escritura2);
    SRC_CONTRATO_PEDIDO.pGrabaError(0,'Oracle',SQLERRM,SYSDATE,iorecError);
    commit;
    End;
    END;
    Any suggestion will be valid.
    Thanks

    Try closing file before calling
    SRC_REG_APISGOSDDR.P4_REGISTRO(....);
    first close files :
    UTL_FILE.FCLOSE(archivo_escritura);
    UTL_FILE.FCLOSE(archivo_escritura2);
    then call or comment this procedure and try:
    SRC_REG_APISGOSDDR.P4_REGISTRO(lcNo_pedido, lcId_pedido, lcNo_protocolo, lcCads_cant_os, lccads_numero_os, lvNom_arch_salida_formato);
    Murali.Ramasamy

  • Problems with UTL_FILE.FCOPY

    I am using UTL_FILE.FCOPY to copy a O/p file created in my package to a different location. Initially, i got INVALID File operation errors & INVALID DIReCTORY PATH error (due to syntax & access issues). I have corrected all those. Right now, my code is executing without errors but the file is not getting copied to the Destination location.
    Note: Both Source & Destination location is Unix path. I do have access to the paths and able to create files. I checked to see whether it is hidden but could not trace anything. When I am using TST_DATA_DIR as destination location as well, there are no problems.
    Any suggestions on what the issue could be?
    My source location is TST_DATA_DIR value is '/u01/app/MTST/Web/user';
    p_file_name := 'TEST3.DAT';
    v_tst_dir VARCHAR2(70):= '/u01/app/MTST/appl/reports';
    Utl_File.Fcopy (
    src_location => 'TST_DATA_DIR',
    src_filename => p_file_name,
    dest_location => v_tst_dir,
    dest_filename => 'fin7.DAT' );

    user13641802 wrote:
    I am using UTL_FILE.FCOPY to copy a O/p file created in my package to a different location. Initially, i got INVALID File operation errors & INVALID DIReCTORY PATH error (due to syntax & access issues). I have corrected all those. Right now, my code is executing without errors but the file is not getting copied to the Destination location.
    Note: Both Source & Destination location is Unix path. I do have access to the paths and able to create files. I checked to see whether it is hidden but could not trace anything. When I am using TST_DATA_DIR as destination location as well, there are no problems.
    Any suggestions on what the issue could be?
    My source location is TST_DATA_DIR value is '/u01/app/MTST/Web/user';
    p_file_name := 'TEST3.DAT';
    v_tst_dir VARCHAR2(70):= '/u01/app/MTST/appl/reports';
    Utl_File.Fcopy (
    src_location => 'TST_DATA_DIR',
    src_filename => p_file_name,
    dest_location => v_tst_dir,
    dest_filename => 'fin7.DAT' );You need to set up a seperate directory object for your destination directory and refer to that by name rather than the path e.g.
    create directory TST_DATA_DIR as '/u01/app/MTST/Web/user';
    create directory TST_DEST_DIR as '/u01/app/MTST/appl/reports';Edit: p.s. don't forget to grant read and/or write permissions on the directory objects if necessary (i.e. if the creation of those objects is by a different user to the one using them)
      p_file_name := 'TEST3.DAT';
      Utl_File.Fcopy (
           src_location  => 'TST_DATA_DIR',
           src_filename  => p_file_name,
           dest_location => 'TST_DEST_DIR',
           dest_filename => 'fin7.DAT' );Edited by: BluShadow on 06-Jan-2011 08:38

  • Problem Using UTL_FILE package ORA-29285

    Dear All,
    I would very much appreciate your help.
    I am trying to export data form a table.
    The version of the DB is 10.2.0.4
    I am using the following procedure:
    create or replace
    procedure EXPORT_FRAME(
    dir IN VARCHAR2, filename IN VARCHAR2) IS
    f utl_file.file_type;
      cursor frame is
        Select *
        from test_complete_frame_2008;
    begin
      f:= utl_file.fopen (dir, filename,'w');
      FOR a IN frame
      Loop
        utl_file.put_line (f,
            '"'||a.COM_DATA_ID || '";"' ||
               a.COM_DATA_SET_ID || '";"'||
                a.NSI || '";"'||
                a.FRAME_ID || '";"'||
                a.STATUS_FRAME || '";"'||
                TO_CHAR(a.FRAME_REFERENCE_DATE, 'dd/mm/yyyy') || '";"'||
                TO_CHAR(a.DATE_OF_SELECTION, 'dd/mm/yyyy')  || '";'||
                a.EU_LEU_ID || ';"'||
                a.NSA_ID || '";"'||
                a.SOURCE_IDENTITY || '";"'||
                TO_CHAR(a.REF_DATE_LEU_IDENTITY, 'dd/mm/yyyy') || '";"'||
                a.NATIONAL_ID || '";"'||
                a.REF_DATE_NATIONAL_ID || '";"'||
                a.DUNS_NUMBER || '";"'||
                TO_CHAR(a.REF_DATE_DUNS_NUMBER, 'dd/mm/yyyy') || '";"'||
                a.BVD_ID || '";"'||
                TO_CHAR(a.REF_DATE_BVD_ID, 'dd/mm/yyyy') || '";"'||
                a.NAME_LEGAL_UNIT || '";"'||
                a.LEGAL_FORM_EGR || '";"'||
                a.SOURCE_LEGAL_FORM || '";"'||
                TO_CHAR(a.REF_DATE_LEGAL_FORM, 'dd/mm/yyyy') || '";"'||
                a.TYPE_OF_LEGAL_UNIT || '";"'||
                a.SOURCE_CODE_TYPE_OF_LEU || '";"'||
                TO_CHAR(a.REF_DATE_TYPE_OF_LEU, 'dd/mm/yyyy') || '";"'||
                a.STATUS_LEU || '";"'||
                a.SOURCE_CODE_STATUS_LEU || '";"'||
                TO_CHAR(a.REF_DATE_STATUS_LEU, 'dd/mm/yyyy') || '";"'||
                a.POST_DELIVERY_POINT || '";"'||
                a.CITY_NAME || '";"'||
                a.POSTAL_CODE || '";"'||
                a.STATE_NAME || '";"'||
                a.COUNTRY_CODE_BOP || '";"'||
                a.COUNTRY_ACCESS_CODE || '";"'||
                a.TELEPHONE_NUMBER || '";"'||
                a.FAX_NUMBER || '";"'||
                TO_CHAR(a.DATE_OF_INCORPORATE, 'dd/mm/yyyy') || '";"'||
                a.SOURCE_DATE_OF_INCORP || '";"'||
                TO_CHAR(a.REF_DATE_DATE_OF_INCORP, 'dd/mm/yyyy') || '";"'||
                TO_CHAR(a.DATE_OF_LIQUIDATION, 'dd/mm/yyyy') || '";"'||
                a.SOURCE_DATE_OF_LIQ || '";"'||
                TO_CHAR(a.REF_DATE_DATE_OF_LIQ, 'dd/mm/yyyy') || '";"'||
                a.NACE_CODE || '";"'||
                a.VERSION_NACE || '";"'||
                a.SOURCE_CODE_NACE || '";"'||
                TO_CHAR(a.REF_DATE_NACE, 'dd/mm/yyyy') || '";"'||
                a.NUMBER_PERS_EMPLOYED || '";"'||
                a.SOURCE_CODE_PERS_EMPL || '";"'||
                a.CONS_PERSON_EMPLOYED || '";"'||
                TO_CHAR(a.REF_DATE_PERS_EMPLOYED, 'dd/mm/yyyy') || '";"'||
                a.SPECIAL_PURP_ENTITY_CODE || '";"'||
                a.SOURCE_CODE_SPE || '";"'||
                TO_CHAR(a.REF_DATE_SPE_CODE, 'dd/mm/yyyy') || '";"'||
                a.EMAIL_ADDRESS || '";"'||
                TO_CHAR(a.REF_DATE_EMAIL_ADDRESS, 'dd/mm/yyyy') || '";"'||
                a.WEB_ADDRESS || '";"'||
                TO_CHAR(a.REF_DATE_WEB_ADDRESS, 'dd/mm/yyyy') || '";"'||
                a.P_EU_LEU_ID || '";"'||
                a.P_NAME_LEGAL_UNIT || '";"'||
                a.P_COUNTRY_CODE_BOP || '";"'||
                a.STATUS_RELATIONSHIP || '";"'||
                a.PERCENTAGE || '";"'||
                a.KIND_OF_CONTROL || '";"'||
                a.SOURCE_CODE_RELATIONSHIP || '";"'||
                TO_CHAR(a.REF_DATE_RELATIONSHIP, 'dd/mm/yyyy') || '";"'||
                a.GLOBAL_LEVEL || '";"'||
                a.GGH_EU_LEU_ID || '";"'||
                a.GGH_NAME_LEGAL_UNIT || '";"'||
                a.GGH_COUNTRY_CODE_BOP || '";"'||
                a.GGH_NSA_ID || '";"'||
                a.GGH_DUNS_NUMBER || '";"'||
                a.GGH_BVD_ID || '";"'||
                a.GGH_SOURCE_IDENTITY || '";"'||
                a.GLOBAL_EG_ID || '";"'||
                a.GLOBAL_EG_NAME || '";"'||
                a.TOP_MNE_IND || '";"'||
                a.GEG_PERSONS_EMPLOYED || '";"'||
                a.GEG_SOURCE_CODE_PERS_EMPL || '";"'||
                TO_CHAR(a.GEG_REF_DATE_PERS_EMPL, 'dd/mm/yyyy') || '";"'||
                a.NUMBER_OF_LEGAL_UNITS || '";"'||
                a.GEG_NACE_CODE_DIV || '";"'||
                a.GEG_SOURCE_CODE_NACE || '";"'||
                TO_CHAR(a.GEG_REF_DATE_NACE, 'dd/mm/yyyy') || '";"'||
                a.GEG_CONS_TURNOVER || '";"'||
                a.GEG_VALUTA_CONS_TURNOVER || '";"'||
                TO_CHAR(a.GEG_BEGIN_CONS_TURNOVER, 'dd/mm/yyyy') || '";"'||
                TO_CHAR(a.GEG_END_CONS_TURNOVER, 'dd/mm/yyyy') || '";"'||
                a.GEG_SOURCE_CONS_TURNOVER || '";"'||
                TO_CHAR(a.GEG_REF_DATE_C_TURNOVER, 'dd/mm/yyyy') || '";"'||
                a.GEG_TOTAL_ASSETS || '";"'||
                a.GEG_VALUTA_TOTAL_ASSETS || '";"'||
                a.GEG_SOURCE_TOTAL_ASSETS || '";"'||
                TO_CHAR(a.GEG_REF_DATE_TOTAL_ASSETS, 'dd/mm/yyyy') || '";"'||
                a.GEG_WEB_ADDRESS || '";"'||
                a.GDC_EU_LEU_ID || '";"'||
                a.GDC_NAME_LEGAL_UNIT || '";"'||
                a.GDC_COUNTRY_CODE_BOP || '";"'||
                a.GDC_NSA_ID || '";"'||
                a.GDC_DUNS_NUMBER || '";"'||
                a.GDC_BVD_ID || '";"'||
                a.GDC_SOURCE_IDENTITY || '";"'||
                a.REP_EU_LEU_ID || '";"'||
                a.REP_NAME_LEGAL_UNIT || '";"'||
                a.REP_POST_DELIVERY_POINT || '";"'||
                a.REP_POSTAL_CODE || '";"'||
                a.REP_STATE_NAME || '";"'||
                a.REP_CITY_NAME || '";"'||
                a.REP_COUNTRY_CODE_BOP || '"'
           UTL_FILE.new_line (f);
      END LOOP;
      UTL_FILE.new_line (f);
      UTL_FILE.fclose(f);
        EXCEPTION
          WHEN NO_DATA_FOUND
            THEN dbms_output.put_line ('FAILED');
    END EXPORT_FRAME;I get an error message:
    Error starting at line 1 in command:
    begin EXPORT_FRAME ('EXP','test2.csv'); end;
    Error report:
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 136
    ORA-06512: at "SYS.UTL_FILE", line 813
    ORA-06512: at "EGR.EXPORT_FRAME", line 13
    ORA-06512: at line 1
    29285. 00000 - "file write error"
    *Cause:    Failed to write to, flush, or close a file.
    *Action:   Verify that the file exists, that it is accessible, and that
    it is open in write or append mode.
    Any idea?
    Thanks in advance!

    By default UTL_FILE.FOPEN opens file with record size up to 1024 characters (including newline). Most likely your code exceeds 1024. Change:
    f:= utl_file.fopen (dir, filename,'w');to something like (assuming none of your records will exceed 10000)
    f:= utl_file.fopen (dir, filename,'w',10000);SY.

  • Problem with utl_file package

    Hi guys.
    I was trying I/O in oracle using utl_file packege the codes written my me was:
    DECLARE
    Temp UTL_FILE.File_Type;
    BEGIN
    Temp:=UTL_FILE.Fopen('/DOGS','TEST.txt','w');
    UTL_FILE.Put(Temp,'Hell');
    UTL_FILE.FFLUSH(Temp);
    UTL_FILE.Fclose(Temp);
    EXCEPTION
    WHEN UTL_FILE.INVALID_PATH THEN
    DBMS_OUTPUT.PUT_LINE('PATH');
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    DBMS_OUTPUT.PUT_LINE('HANDLE');
    END;
    but its going state to exception invalid_path can any one help me out please.
    the entry in init.ora file was
    utl_file_dir="c:/help"
    please help me out please ur help will be appreciated. thanx
    nikhil
    null

    Nikhil,
    If we consider the following line from your code:
    Temp:=UTL_FILE.Fopen('/DOGS','TEST.txt','w');
    The first parameter in the FOPEN function ('/DOGS') is not a file system directory name, but an Oracle DB directory name. You need to create the directory thus:
    CREATE DIRECTORY dogs AS 'C:\help' ;
    You then need to permit the database server to access the physical directory by setting UTL_FILE_DIR as follows:
    UTL_FILE_DIR = 'C:\help'
    in init.ora. Don't forget to bounce the DB!
    Now you can open the file with:
    Temp:=UTL_FILE.FOPEN('dogs','TEST.txt','w');

  • Problems with UTL_FILE.PUT_LINE and special charcters

    Hi,
    in a ETL process I'm loading data with an external table , split the file and write the result into files using UTL_FILE.PUT_LINE. But there are special characters in the sourcefile which are converted wrong in the outputfile.
    My external table:
    CREATE TABLE EXTFILESPLIT
      TABLENAME  VARCHAR2(30 BYTE),
      TABLEDATA  VARCHAR2(3970 BYTE)
    ORGANIZATION EXTERNAL
      (  TYPE ORACLE_LOADER
         DEFAULT DIRECTORY IMPORT_HOST
         ACCESS PARAMETERS
           ( RECORDS DELIMITED BY NEWLINE CHARACTERSET WE8ISO8859P1
       BADFILE IMPORT_HOST_LOG:'import.dat.bad' LOGFILE
       IMPORT_HOST_LOG:'import.dat.log' DISCARDFILE 
       IMPORT_HOST_LOG:'import.dat.dsc' FIELDS RTRIM REJECT ROWS WITH ALL NULL FIELDS
      ( tablename CHAR(30),  tabledata CHAR(3970)) )
         LOCATION (IMPORT_HOST:'import.dat')
    REJECT LIMIT 0
    NOPARALLELPart of my PL/SQL procedure:
    CREATE OR REPLACE PROCEDURE SPLIT_IMPORT_FILE(p_fileName VARCHAR2) AS
      CURSOR splitFileCursor IS
         SELECT tablename,tabledata FROM extfilesplit ORDER BY tablename;
      TYPE extFileSplitTable IS TABLE OF extfilesplit%ROWTYPE; 
      splitFileTab extFileSplitTable;
      currentFile UTL_FILE.FILE_TYPE;
    BEGIN
      OPEN splitFileCursor;
      FETCH splitFileCursor BULK COLLECT INTO splitFileTab LIMIT 10000;
      WHILE splitFileTab.COUNT > 0 LOOP
    IF curOutputFileName = lastOutputFileName THEN
            UTL_FILE.PUT_LINE(currentFile,splitFileTab(i).tabledata,FALSE);
          ELSE
            UTL_FILE.FCLOSE(currentFile);
            currentFile:=UTL_FILE.FOPEN('IMPORT_HOST_SPLIT',curOutputFileName||'.split','a',4000);
            UTL_FILE.PUT_LINE(currentFile,splitFileTab(i).tabledata,FALSE);
          END IF;
            lastOutputFileName:=curOutputFileName;
        END LOOP;
    ...An Example of the inputfile
    TBL0200GESCHBEZ               þ150064147þ,þ150064147þ,þÄKÜKÜþ,þ0þ,þþ,þPINþ,þ1þÐThe result:
    þ150064147þ,þ150064147þ,þÄKÜKÜþ,þ0þ,þþ,þPINþ,þ1þÐI also tried different charactersets in the external table (WE8ISO8859P1, WE8ISO8859P15, WE8MSWIN1252) but it didn't help.
    When I looked at the data in the external table everything was ok.
    My NLS session settings:
    PARAMETER             VALUE
    NLS_LANGUAGE             GERMAN
    NLS_TERRITORY             GERMANY
    NLS_CURRENCY             €
    NLS_ISO_CURRENCY        GERMANY
    NLS_NUMERIC_CHARACTERS     ,.
    NLS_CALENDAR             GREGORIAN
    NLS_DATE_FORMAT             DD.MM.RR
    NLS_DATE_LANGUAGE       GERMAN
    NLS_SORT             GERMAN
    NLS_TIME_FORMAT             HH24:MI:SSXFF
    NLS_TIMESTAMP_FORMAT    DD.MM.RR HH24:MI:SSXFF
    NLS_TIME_TZ_FORMAT     HH24:MI:SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT     DD.MM.RR HH24:MI:SSXFF TZR
    NLS_DUAL_CURRENCY     €
    NLS_COMP             BINARY
    NLS_LENGTH_SEMANTICS     BYTE
    NLS_NCHAR_CONV_EXCP     FALSEDim

    According to Metalink note:
    Subject: Character set conversion when using UTL_FILE
    Doc ID: Note:227531.1 Type: BULLETIN
    Last Revision Date: 10-JUL-2006 Status: PUBLISHED
    UTL_FILE does not make any character set conversion.
    What is your database character set ?

  • Error Using Directories and UTL_FILE package

    Dear All, I have a problem using UTL_FILE package...
    When I'm trying to write into a directory I get the following error message:
    ORA-29283: invalid file open
    I have a Directory named "TMPDIRPD". I checked the permissions over this directory and found that
    'OPS$PDRVBPP' user has OS permissions over it. I supposed that it was the user used to validate permissions.
    Plus, I verified that user "OPS$PDRDVBPP" has read/write permission into directory with this query:
    SELECT TP.grantee,
    TP.privilege
    FROM dba_tab_privs TP,
    dba_role_privs RP
    WHERE TP.table_name = 'TMPDIRPD'
    AND TP.grantee = RP.granted_role
    AND rp.grantee = 'OPS$PDRDVBPP';
    But I'm getting the same error message.
    Then I saw that 'OPS$PDRDVBPP' user calls UTL_FILE package through another package, and isn't the owner of it...
    This package - who belongs to another database user - is using the OS user who owns the Oracle Installation instead 'OPS$PDRVBPP'. Isn't it?
    I also checked that operative system user has read-write permissions, and asked it to the OS Administrator. He told me that oracle user has read-write permissions over this directory too... I don't know what more else can be wrong.
    Have anyone some idea to fix this?

    Roman, I sorry about missed info.
    This is the version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    "CORE     10.2.0.4.0     Production"
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    It's running over a Unix server (I really don´t know the exact version but it's a suse Linux).
    I though in ORACLE Directory object named TMPDIRPD, and its directory_path defined like /companyFiles/thishost/proj/pdrdvbpp/appfiles/tmp (OS Directory).
    I wrote into a OS directory using one of the procedures or functions inside the UTL_FILE package (SYS.UTL_FILE.FOPEN(parameter_path,parameter_file,parameter_io)).
    Here it goes an example of code.
    DECLARE
    v_AbroLog UTL_FILE.FILE_TYPE;
    BEGIN
    v_AbroLog := UTL_FILE.FOPEN('TMPDIRPD','log_prueba_utl.'||to_char(sysdate,'mmddy
    yyy'), 'a');
    UTL_FILE.PUT_LINE(v_AbroLog,'PRUEBA OK');
    UTL_FILE.FCLOSE(v_AbroLog);
    END;
    quit
    SQL> @test_utl.sql;
    DECLARE
    ERROR at line 1:
    ORA-29283: invalid file open
    some other generic error messages
    This error happens when the file doesn't exists.

  • Read_error

    does anyone the reasons why you get a read_error from utl_file.get_line when trying to read a file on a unix server but the file(pdf) was generated on a windows server. i presume it has something to do with encoding but can anyone explain this further

    Is this the same problem that is being discussed in Problems with utl_file and reading pdf's? Or are these separate issues?
    Justin

  • Problems with moving files to ora directory UTL_FILE.PUT_RAW - ORA-29285

    hi,
    i'm using apex 4.1
    i have a procedure which moves my file from apex_application_files to ORA directory.
    if i choose a text file or small word document which is 1kb, it works. but if i have pdf file (85kb) or word document (16kb) it gives me ORA-29285: file write error
    what's my problem?
    PROCEDURE put_file_to_server (p_filename IN VARCHAR2,p_cert_type IN VARCHAR2,p_cert_pk IN NUMBER)
    AS
    l_file UTL_FILE.file_type;
    l_blob_len INTEGER;
    l_pos INTEGER := 1;
    l_amount BINARY_INTEGER := 32767;
    l_buffer RAW (32767);
    v_new_filename VARCHAR2(100);
    v_bfile BFILE ;
    BEGIN
    -- delete from apex_application_files;
    --Neuen Dateinamen generieren
    v_new_filename := p_cert_type||'_'||p_cert_pk;
    v_bfile := BFILENAME (v_directory, v_new_filename);
    --Datei erstellen
    l_file := UTL_FILE.fopen(v_directory,v_new_filename,'w');
    IF DBMS_LOB.FILEEXISTS (v_bfile) = 1 THEN
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'File exists');
    FOR rec IN (select blob_content lblob from apex_application_files where rownum = 1)
    LOOP
    l_blob_len := DBMS_LOB.getlength(rec.lblob);
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Filesize is '||l_blob_len);
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.read (rec.lblob, l_amount, l_pos, l_buffer);
    UTL_FILE.put_raw (l_file, l_buffer, FALSE);
    l_pos := l_pos + l_amount;
    END LOOP;
    COMMIT;
    END LOOP;
    --Datei schließen
    UTL_FILE.fclose(l_file);
    else
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Datei doesn't exist');
    end if;
    EXCEPTION
    WHEN OTHERS
    THEN
    -- Close the file if something goes wrong.
    IF UTL_FILE.is_open (l_file) THEN
    UTL_FILE.fclose (l_file);
    END IF;
    delete from apex_application_files;
    RAISE;
    delete from apex_application_files;
    END put_file_to_server;

    Sorry but din't test this...Can you give it a try and see if this works?
    PROCEDURE put_file_to_server(
        p_filename  IN VARCHAR2,
        p_cert_type IN VARCHAR2,
        p_cert_pk   IN NUMBER)
    AS
      l_file UTL_FILE.file_type;
      l_blob_len INTEGER;
      l_pos      INTEGER      := 1;
      l_amount BINARY_INTEGER := 32767;
      l_buffer RAW (32767);
      v_new_filename VARCHAR2(100);
      v_bfile BFILE ;
      vblob BLOB;
      vstart NUMBER := 1;
      my_vr RAW(32000);
      bytelen NUMBER := 32000;
      LEN     NUMBER;
    BEGIN
      -- delete from apex_application_files;
      --Neuen Dateinamen generieren
      v_new_filename := p_cert_type||'_'||p_cert_pk;
      v_bfile        := BFILENAME (v_directory, v_new_filename);
      --Datei erstellen
      --l_file                          := UTL_FILE.fopen(v_directory,v_new_filename,'w');
      l_file                          := UTL_FILE.fopen(v_directory,v_new_filename, 'WB', 32760);
      IF DBMS_LOB.FILEEXISTS (v_bfile) = 1 THEN
        cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'File exists');
        FOR rec IN
        (SELECT blob_content lblob,
          LENGTH(blob_content) LEN
        FROM apex_application_files
        WHERE rownum = 1
        LOOP
          cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Filesize is '|| LEN);
          IF LEN < 32760 THEN
            utl_file.put_raw(l_file,lblob);
            utl_file.fflush(l_file);
          ELSE -- write in pieces
            vstart      := 1;
            WHILE vstart < LEN
            LOOP
              dbms_lob.read(vblob,bytelen,vstart,my_vr);
              utl_file.put_raw(l_file,my_vr);
              utl_file.fflush(l_file);
              -- set the start position for the next cut
              vstart := vstart + bytelen;
              -- set the end position if less than 32000 bytes
              x         := x - bytelen;
              IF x       < 32000 THEN
                bytelen := x;
              END IF;
            END LOOP;
          END IF;
         END LOOP;
        ELSE
          cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Datei doesnt exist');
        END IF;
        utl_file.fclose(l_file);
      EXCEPTION
      WHEN OTHERS THEN
        -- Close the file if something goes wrong.
        IF UTL_FILE.is_open (l_file) THEN
          UTL_FILE.fclose (l_file);
        END IF;
        DELETE FROM apex_application_files;
        RAISE;
        DELETE FROM apex_application_files;
      END put_file_to_server;Edited by: Vitor Rodrigues on 17/Fev/2012 12:03

  • UTL_FILE, Extra CRFL's, possible OS interpretation problem.

    Greetings,
    DISCLAIMER:
    I am an oracle noob so if I make a mistake in forum etiquette or have not checked all available documentation or have made an assumption that is incorrect ( or noobish ) or am unaware of a tool better suited to the task I am trying to accomplish..
    Please don’t flame me, I am learning. Give me constructive replies and I will learn, I promise.
    My environment: 10G XE DB running on Server 2k3. Developing in SQLDEV 1.54
    I am attempting to dump the contents of a CLOB to a file on the OS disc. Due to formatting restrictions, the contents of the file written to disc must be EXACTLY the contents of the CLOB, character per-per character, verbatim.
    Here is an example anon block that will give you the essentials of the way I am attempting to accomplish this:
    DECLARE
    l_clob CLOB ;
    l_output_file utl_file.file_type;
    BEGIN
    l_clob := 'Hello my name is George!' || chr(13) || chr(10) ;
    l_clob:= l_clob || 'Would you like to play a game?' || chr(13) || chr(10);
    l_clob := l_clob || 'It will be fun, I promise..' || chr(13) || chr(10);
    dbms_output.put_line( dbms_lob.getlength(l_clob));
    l_output_file := utl_file.fopen( TEST_DIR' , 'test.txt' ,'W', max_linesize=> 32767 );
    utl_file.put( l_output_file , l_clob );
    utl_file.fflush( l_output_file);
    utl_file.fclose( l_output_file );
    utl_file.fclose_all;
    END;
    Here you can see where I put a few lines into my clob, I manually append the CRLF using the CHR function, since I cant accurately reproduce a non-printable character in a string value. This is important because the Clob I am attempting to write to disc contains CRLF’s as part of its data, these must be preserved. Also note that I am writing this to the file using utl_file.PUT not PUT_LINE, again, because the disk file must be the clob verbatim, I cant use put_line because it adds a “new line character” at the end of the data it writes.
    Ignore the DMBS_OUTPUT line , I will get back to that in a bit.
    I execute this bit of code and get a file text.txt. What I expected to see was:
    “'Hello my name is George!
    Would you like to play a game?
    'It will be fun, I promise..”
    What I actually got was:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp001.jpg!
    Looking at this in notepad++ we can expose the non-printable chars:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp002.jpg!
    Using notepad ++ we can see that an extra CR ( CHR(13)) has been pre-pended to the CRLF. We can confirm this is not an artifact of viewing this in notepad by looking at the file size of the output file and comparing it to the size of the clob.
    The DBMS_OUTPUT line indicates ( in my test case) clob size of 87 characters. If you take the time to count you will see this is correct. 81 printable characters that we see, and the 6 non-printable chars to accomplish the CRLF’s.
    However if we look at the file size:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp003.jpg!
    So that’s 87 + our 3 “ninja ” CR’s.
    For my purposes this is a deal-breaking problem. The contents of my output file must be exactly the contents of my clob, byte for byte. So this extra CR is a big big problem.
    Where is it coming from? I started thinking about the “new line character” that the PUT_LINE procedure uses and, had a hunch that perhaps since the DB is OS independent, it might be passing one of the non-printable chars to the OS as “new line” and letting the os worry about what that means on disk. With that in mind I did some further testing:
    DECLARE
    l_clob CLOB ;
    l_output_file utl_file.file_type;
    BEGIN
    l_clob := 'Incoming lf->'|| chr(10) ;
    l_clob:= l_clob || 'Incoming cr->' || chr(13);
    clob:= lclob || 'Incoming CRLF->' || chr(13) || chr(10);
    l_output_file := utl_file.fopen( TEST_DIR' , 'test.txt' ,'W', max_linesize=> 32767 );
    utl_file.put( l_output_file , l_clob );
    utl_file.fflush( l_output_file);
    utl_file.fclose( l_output_file );
    utl_file.fclose_all;
    END;
    This code results in:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp004.jpg!
    Looking at this it becomes obvious that the CHR(10) is being written to disc as TWO characters ( CR LF). So my assumption must be correct, that the DB is passing CHR(10) to the OS as “newline” and the OS ( Windows in my case ) is interpreting this as ‘CRLF.’
    This makes sense since it seems to be widely known ( though not to me , I am shaky on this part ) that “newline” in unix is just CHR(10), and in windows its CHR(10)||CHR(13).
    So I seem to have isolated my problem. Now finally my question.. How to I get around this?
    Google searches and searches on this forum yeilded only marginal help, something about passing this file through an FTP server.. ?. The only marginal help was in post # 3298335. Nothing that really answers my question though.
    Is there a setting my DBA can set to change this behavior? Is there a different way ( PLSQL) to write the file that might mitigate this? Don’t say put the DB on unix, that’s not an option.
    Let me know what you think…
    -VAF

    Hi,
    Also you should check that the directory name is enclosed between '. TEST_DIR is an Oracle directory object that maps a real directory path in the filesystem (check privileges).
    Like:
    DECLARE
        l_clob CLOB;
        l_output_file utl_file.file_type;
    BEGIN
        l_clob := 'Hello my name is George!' || CHR(13) || CHR(10);
        l_clob := l_clob || 'Would you like to play a game?' || CHR(13) || CHR(10);
        l_clob := l_clob || 'It will be fun, I promise..' || CHR(13) || CHR(10);
        dbms_output.put_line(dbms_lob.getlength(l_clob));
        l_output_file := utl_file.fopen('TEST_DIR', 'test.txt', ' W', max_linesize => 32767);
        utl_file.put(l_output_file, l_clob);
        utl_file.fflush(l_output_file);
        utl_file.fclose(l_output_file);
    END;Tip: to post formatted code you must enclose it between {noformat}{noformat} tags (start and end tags are the same).
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem in writiing data to UTL_File

    Hello Friends,
    I'm using UTL_FILE to write the data into csv file, but in the table 1 description column is there which contains 3000 characters.
    My problem is i'm not able to write more than 750 characters in csv file and if i tried to do so then get the FILE_WRITE_ERROR. error msg
    I tried by breaking the column into 3 different strings by giving the column as diffrent-different aliases but facing the same problem.
    Please help me to write all the characters i.e 3000 charcters in a file.
    Is there any character length limitation in csv file?
    Regards,
    Anand

    As others have stated MAX_LINESIZE parameter of FOPEN is what matters.
    SQL> create table t(c1 varchar2(4000), c2 varchar2(4000))
      2  /
    Table created.
    SQL> insert into t values(rpad('*',4000,'*'),rpad('#',4000,'#'))
      2  /
    1 row created.
    SQL> commit
      2  /
    Commit complete.
    SQL> select length(c1), length(c2) from t
      2  /
    LENGTH(C1) LENGTH(C2)
          4000       4000
    SQL> create or replace directory utl_dir as 'e:\oracle\log_files\utl_akivanew'
      2  /
    Directory created.
    SQL> declare
      2     lFile_Handle utl_file.file_type;
      3     lc1 t.c1%type;
      4     lc2 t.c2%type;
      5  begin
      6     select c1, c2 into lc1, lc2 from t;
      7
      8     lFile_Handle := utl_file.fopen('UTL_DIR','test.csv','W', 10000);
      9
    10     utl_file.put_line(lFile_handle, lc1||','||lc2);
    11
    12     utl_file.fclose(lFile_Handle);
    13  end;
    14  /
    PL/SQL procedure successfully completed.
    SQL> declare
      2     lFile_Handle utl_file.file_type;
      3     lc1 t.c1%type;
      4     lc2 t.c2%type;
      5  begin
      6     select c1, c2 into lc1, lc2 from t;
      7
      8     lFile_Handle := utl_file.fopen('UTL_DIR','test.csv','W', 7000);
      9
    10     utl_file.put_line(lFile_handle, lc1||','||lc2);
    11
    12     utl_file.fclose(lFile_Handle);
    13  end;
    14  /
    declare
    ERROR at line 1:
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 69
    ORA-06512: at "SYS.UTL_FILE", line 604
    ORA-06512: at line 12

  • Problem in using UTL_FILE Package

    Dear Mates,
    I am trying to make use of UTL_FILE for inseting data in to the tables by reading the contents of a text file. I have set the UTL_FILE_DIR parameter by giving the path. Still i am not able to insert the records to the table.
    The error I am getting is
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "PRASANNA.LOADSTUDENTS", line 61
    ORA-06512: at line 1
    I have set the parameter UTL_FILE_DIR in INIT<SID>.ORA as
    UTL_FILE_DIR=C:\developer
    please help me out
    It will be helpful if you can mail me at [email protected]

    ORA-06512: at "PRASANNA.LOADSTUDENTS", line 61how looks like line 61 in your PRASANNA.LOADSTUDENTS function?
    what's happening there?
    From "Oracle Product Document Library":
    ORA-06512 at string line string
    Cause: Backtrace message as the stack is unwound by unhandled exceptions.
    Action: Fix the problem causing the exception or write an exception handler for this condition. Or you may need to contact your application administrator or database administrator.

  • Having problem in recognising file using utl_file package..

    Hi,
    I am using utl_file utility to read the CSV file, utl_file.fopen function is useed to open file. This fopen function has three input parameters, second parameter is file name. My problem is that, i have to read file on daily basis. File name will be like:- DDMMYYYYHHMISS. Last six characters are for hour minute second of the file generation time. If the name has only DDMMYYYY then I can give the file name like TO_CHAR(SYADATE,'DDMMYYYY'), because on a particular date its same for the whole day. But hours, minutes and seconds will be of the time when the file is generated, it may be different for different days. In this condition how can I standardize the value for file name parameter in fopen function.
    Thanks in advance.

    Bharat Kaushik wrote:
    Actually.....
    I am gettting file from some other place..... And those people are not agreed to send file without exact time.JAVA solution is here
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:7506780031005
    Or if you want PL/SQL .. (May Be kiddy)
    --Please Note: SYSDATE is 26th in our DB.
    SQL> declare
      2   fp utl_file.file_type;
      3   dt date := trunc(sysdate);
      4  begin
      5   while (dt <= sysdate) loop
      6    begin
      7      fp := utl_file.fopen('OGL_REPORT_ACCESS','TEST'||to_char(dt,'ddmmyyyyhh24miss')||'.csv','r');
      8      dbms_output.put_line('TEST'||to_char(dt,'ddmmyyyyhh24miss'));
      9      utl_file.fclose(fp);
    10      exit;
    11    exception
    12     when utl_file.INVALID_OPERATION then
    13      null;
    14    end;
    15    dt := dt + 1/24/60/60;
    16   end loop;
    17  end;
    18  /
    TEST26042009010102
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:03.45
    SQL> select sysdate from dual;
    SYSDATE
    26-APR-09

  • Problem with access rights by using UTL_FILE

    Hi all,
    Could you please help me with the following problem. A search on this forum did not result in the final solution:
    - We are using an Oracle XE database on an Oracle VM instance
    - I want to export a lot of data to the filesystem, by using UTL_FILE.
    - The package that calls UTL_FILE, should be installed in the database schema 'XXCUST'.
    - I have created a folder '/home/oracle/XX_EXPORT_FOLDER' on the filesystem
    - I have created a database directory 'XX_EXPORT', which links to this folder
    - I have granted read and write to public for this folder
    - I use the following script to export the files:
    DECLARE
    l_file_handle UTL_FILE.FILE_TYPE;
    BEGIN
    l_file_handle := UTL_FILE.FOPEN( location => 'XX_EXPORT', filename => 'test.txt',open_mode => 'W', max_linesize => 100);
    UTL_FILE.PUT_LINE(l_file_handle, 'TEST');
    UTL_FILE.FCLOSE(l_file_handle);
    END;
    When I run this script with the user 'XXCUST' I get the following error:
    ORA-06521: PL/SQL: Error mapping function
    ORA-06512: at "SYSTEM.UTL_FILE", line 41
    ORA-06512: at "SYSTEM.UTL_FILE", line 478
    ORA-06512: at line 15
    06521. 00000 - "PL/SQL: Error mapping function"
    *Cause:    An error was detected by PL/SQL trying to map the mentioned
    function dynamically.
    *Action:   Check the stacked error (if any) for more details.
    When I run this script with the user 'sys as sysdba', I don't get any errors. My testfile is created successfully.
    What should I do to use this script with user XXCUST?

    What are the permissions on this folder:
    /home/oracle/XX_EXPORT_FOLDER

Maybe you are looking for

  • How to create a report based on the selection of a node of a tree

    Hello, I am new to Oracle Apex and I was trying to build a tree and also an interactive report based on the empno column of the emp table. I have created a tree based on emp table. Now I want to display records of the employee selected in the tree. H

  • How to change the order of entries on the podcast or blog pages?

    Hi, I tried to move entries in the entry area on the podcast page to change the existing order but it seems they stay in the way they were created. Is there any opportunity to change the order of entries after they were created? Thank you, Vlad

  • EDI Parner profile Inbound not available

    hi friends, when i am posting in bound IDOC i am getting the error 'EDI: Partner profile inbound not available'. what could be the problem with this error ? please suggest me with correct solution .. appriciated as quick response. According to the er

  • Camera recommendations for a FCS2 user.

    I'm working with FCS2, and using a 15' MacB Pro. I'm curious what camera you all would recommend for shooting professional quality video, whilst being a little on the cheap side. (I'm a student) A 1000 Internets to you.

  • Downloading the spool

    Hi all, suppose i  have run a report in Background and generated a spool. How to download that spool file  into local file. thnak you sunny.