Invalid directory with UTL_FILE question

Hi all

I am facing problem of invalid directory with UTL_FILE package. Someone could review my mwntioned code below and correct me if something wrong here.

SQL > DECLARE
2 directory VARCHAR2 (300): = "$XXEQ_TOP/data/ar/invoices";
3 name VARCHAR2 (300): = 'GEM5289_04102011 - 03.dat';
4 l_file UTL_FILE.file_type;
5 l_text VARCHAR2 (32767).
6 l_text_not_null VARCHAR2 (32767).
7. START
8 l_file: =.
9 UTL_FILE.fopen (directory,
10 file name,
11 'r ',.
12 32767);
13 UTL_FILE.get_line (l_file, l_text, 32767);
14 DBMS_OUTPUT. Put_line ('first save' | l_text);
15 UTL_FILE.fclose (l_file);
16 EXCEPTION
17 THEN THAN OTHERS THEN
18 DBMS_OUTPUT. Put_line ("Exception" |) SQLERRM);
END 19;
20.
ExceptionORA-29280: invalid directory path

PL/SQL procedure successfully completed.

Concerning
Ramanantsoa nara

UTL_FILE_DIR parameter has been deprecated by oracle for direcory objects because of its security problems.

The right thing to do is to create a directory for instance object:

CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';

Note: This does not create the directory on the file system. Must you do and make sure that oracle has permission to write to this directory of the file system.

Then, grant permission to users who need to access for example...

GRANT READ,WRITE ON DIRECTORY mydir TO myuser;

Then use this object directory inside your FOPEN statement example

fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');

Note: You MUST specify the object name of directory in quotes and uppercase for this works because it is a string that references a database object name that is stored in uppercase by default.

Tags: Database

Similar Questions

  • Error-29280 ORA-29280: invalid directory in UTL_FILE path

    Hi all

    When I execute the code below, I get the error

    ERROR-29280ORA-29280: invalid directory path
    declare
      v_MyFileHandle UTL_FILE.FILE_TYPE;
    BEGIN
      v_MyFileHandle := UTL_FILE.FOPEN('$XXX_OUT', 'HELLO.TXT', 'a');
      
      UTL_FILE.PUT_LINE(v_MyFileHandle,
                        'Hello Again for the Second Time! ' ||
                        TO_CHAR(SYSDATE, 'MM-DD-YY HH:MI:SS AM'));
                        
      UTL_FILE.FCLOSE(v_MyFileHandle);
      
      null;
      
    EXCEPTION
      WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('ERROR ' || TO_CHAR(SQLCODE) || SQLERRM);
        NULL;
    END;
    Please let me know if anyone has an idea about this error.

    Kind regards

    Check if the directory $XXX_OUT is in dba_directories.
    I think that there is no directory of that name and thus the error.
    Apparently $XXX_OUT resembles an UNIX environment variable. If it's a level UNIX environment variable, then it is false... you can't use it here.

    Use in queries

    CREATE OR REPLACE DIRECTORY  as ;
    GRANT READ,WRITE ON  to ;
    
  • with utl_file - save the result in a txt file.

    PLS, help...

    I have a question that I used to use SQL PLUS, using the COIL and it worked very well.

    Now, I'm changing it to pl/sql, which I'll have to use UTL_FILE.

    The problem is that I need to create a file with a pre defined provision.

    Can help you me pls?

    Don't have much experience with UTL_FILE

    Prompt 'Periodo MON-YY:'
    Define periodo = '&periodo'
    SPOOL C:\Users\gtorrens\Documents\GLAudit_2014_2015\gl_audit-&&periodo..txt
    set termout off
    set echo off
    set verify off
    set feedback off
    set serveroutput off
    set head off
    set pagesize 0
    set linesize 608
    set timing off 
    SELECT /*+
             INDEX(GCC GL_CODE_COMBINATIONS_U1)
             INDEX(GJB GL_JE_BATCHES_U1)
             INDEX(FUS FND_USER_U1)
             INDEX(GJL GL_JE_LINES_U1)*/
              rpad(SUBSTR (gcc.segment1, 1, 2),2,' ')
               || rpad(TRANSLATE (
                    CONVERT (
                    TRANSLATE (
                        REPLACE(REPLACE (REPLACE (SUBSTR (emp.de_sgm, 1, 70), CHR (13), ''), CHR (10), ''),CHR (9), '')
                       ,'??????????????????¡§©³º ¨¬²¹¢ª®´»£µ«¼!@#$%*()_+=[]{}/\?:<>|ãÃõÕçÇüÜâÂêÊôÔáÁàÀéÉíÍóÓúÚñшÞ'
                       ,'                                                             aAoOcCuUaAeEoOaAaAeEiIoOuUnN  ')
                   ,'US7ASCII'
                   ,'WE8ISO8859P1') ,'?',' '),70,' ')
               || rpad(SUBSTR (gjs.user_je_source_name, 1, 20),20,' ')
               || lpad(DECODE (NVL (gjl.entered_dr, 0)
                        , 0, DECODE (NVL (gjl.accounted_dr, 0), 0, 'C', 'D')
                        , 'D'),1,' ')
               || lpad(TO_CHAR (gjh.default_effective_date, 'DD-MON-YY'),9,' ')
               || lpad(TO_CHAR (gjh.posted_date, 'DD-MON-YY'),9,' ')
               || lpad(SUBSTR (gcc.segment2, 1, 9),9,' ')
               || rpad(TRANSLATE (
                    CONVERT (
                    TRANSLATE (
                        REPLACE(REPLACE (REPLACE (SUBSTR (cta.de_sgm, 1, 100), CHR (13), ''), CHR (10), ''),CHR (9), '')
                       ,'??????????????????¡§©³º ¨¬²¹¢ª®´»£µ«¼!@#$%*()_+=[]{}/\?:<>|ãÃõÕçÇüÜâÂêÊôÔáÁàÀéÉíÍóÓúÚñшÞ'
                       ,'                                                             aAoOcCuUaAeEoOaAaAeEiIoOuUnN  ')
                   ,'US7ASCII'
                   ,'WE8ISO8859P1') ,'?',' '),100,' ')
               || rpad(SUBSTR (cta.tp_sgm, 1, 10),10,' ')
               || lpad(TO_CHAR (NVL (gjl.accounted_dr, 0),'999G999G999G999G999G990D00'),38,' ')
               || lpad(TO_CHAR (NVL (gjl.accounted_cr, 0),'999G999G999G999G999G990D00'),38,' ')
               || lpad(SUBSTR (gjh.currency_code, 1, 5),5,' ')
               || rpad(TRANSLATE (
                    CONVERT (
                    TRANSLATE (
                        REPLACE(REPLACE (REPLACE (REPLACE (SUBSTR (gjl.description, 1, 150), '|', '@'), CHR (13), ''), CHR (10), ''),CHR (9), '')
                       ,'??????????????????¡§©³º ¨¬²¹¢ª®´»£µ«¼!@#$%*()_+=[]{}/\?:<>|ãÃõÕçÇüÜâÂêÊôÔáÁàÀéÉíÍóÓúÚñшÞ'
                       ,'                                                             aAoOcCuUaAeEoOaAaAeEiIoOuUnN  ')
                   ,'US7ASCII'
                   ,'WE8ISO8859P1') ,'?',' '),150,' ')
               || rpad(gjb.last_updated_by,15,' ')
               || rpad(TRANSLATE (
                    CONVERT (
                    TRANSLATE (
                        REPLACE(REPLACE (REPLACE (SUBSTR (gjb.name, 1, 100), CHR (13), ''), CHR (10), ''),CHR (9), '')
                       ,'??????????????????¡§©³º ¨¬²¹¢ª®´»£µ«¼!@#$%*()_+=[]{}/\?:<>|ãÃõÕçÇüÜâÂêÊôÔáÁàÀéÉíÍóÓúÚñшÞ'
                       ,'                                                             aAoOcCuUaAeEoOaAaAeEiIoOuUnN  ')
                   ,'US7ASCII'
                   ,'WE8ISO8859P1') ,'?',' '),100,' ')
               || lpad(SUBSTR (fus.user_name, 1, 30),30, ' ')
                 linha_utl
          FROM gl_je_lines gjl
             , gl_je_headers gjh
             , gl_code_combinations gcc
             , gl_je_sources gjs
             , gl_je_batches gjb
             , (SELECT 'EMPRESA' id_sgm
                     , a.flex_value cd_sgm
                     , b.description de_sgm
                     , DECODE (SUBSTR (a.compiled_value_attributes, 5, 1)
                             , 'L', 'Passivo'
                             , 'A', 'Ativo'
                             , 'E', 'Despesa'
                             , 'O', 'Pat.Liq'
                             , 'R', 'Receita')
                         tp_sgm
                  FROM fnd_flex_values_vl a, fnd_flex_values_tl b
                 WHERE a.flex_value_set_id = 1015197
                   AND a.flex_value_id = b.flex_value_id
                   AND b.language = 'PTB') emp
             , ( SELECT 'CONTA' id_sgm
                       , a.flex_value cd_sgm
                       , b.description de_sgm
                       , DECODE (SUBSTR (a.compiled_value_attributes, 5, 1)
                               , 'L', 'Passivo'
                               , 'A', 'Ativo'
                               , 'E', 'Despesa'
                               , 'O', 'Pat.Liq'
                               , 'R', 'Receita')
                           tp_sgm
                    FROM fnd_flex_values_vl a, fnd_flex_values_tl b
                   WHERE a.flex_value_set_id = 1015237
                     AND a.flex_value_id = b.flex_value_id
                     AND b.language = 'PTB') cta
             , fnd_user fus
         WHERE gjl.je_header_id = gjh.je_header_id
           AND gjb.je_batch_id = gjh.je_batch_id
           AND gjs.je_source_name = gjh.je_source
           AND gjh.ledger_id = 2041 -- p_nr_livro
           AND gjh.actual_flag = 'A'
           AND gjh.period_name = upper('&&periodo') -- 'JAN-14'
           AND gcc.code_combination_id = gjl.code_combination_id
           AND gcc.segment1 IN ('01', '12', '13', '14', '05', '16', '18')
           AND emp.id_sgm = 'EMPRESA'
           AND emp.cd_sgm = gcc.segment1
           AND cta.id_sgm = 'CONTA'
           AND cta.cd_sgm = gcc.segment2
           AND fus.user_id = gjb.last_updated_by
        --  AND rownum<1001
           ;
        SELECT /*+
             INDEX(GCC GL_CODE_COMBINATIONS_U1)
             INDEX(GJB GL_JE_BATCHES_U1)
             INDEX(FUS FND_USER_U1)
             INDEX(GJL GL_JE_LINES_U1)*/
                    (lpad(TO_CHAR (NVL (SUM(gjl.accounted_dr), 0),'999G999G999G999G999G990D00'),268,' ')) /*VL_DEBITO*/
             ||' '||(lpad(TO_CHAR (NVL (SUM(gjl.accounted_cr), 0),'999G999G999G999G999G990D00'),37 ,' ')) /*VL_CREDITO*/
             ||' '|| TO_CHAR (COUNT (*)) soma /*qtd_reg*/
          FROM gl_je_lines gjl
             , gl_je_headers gjh
             , gl_code_combinations gcc
             , gl_je_sources gjs
             , gl_je_batches gjb
             , (SELECT 'EMPRESA' id_sgm
                     , a.flex_value cd_sgm
                     , b.description de_sgm
                     , DECODE (SUBSTR (a.compiled_value_attributes, 5, 1)
                             , 'L', 'Passivo'
                             , 'A', 'Ativo'
                             , 'E', 'Despesa'
                             , 'O', 'Pat.Liq'
                             , 'R', 'Receita')
                         tp_sgm
                  FROM fnd_flex_values_vl a, fnd_flex_values_tl b
                 WHERE a.flex_value_set_id = 1015197
                   AND a.flex_value_id = b.flex_value_id
                   AND b.language = 'PTB') emp
             , ( SELECT 'CONTA' id_sgm
                       , a.flex_value cd_sgm
                       , b.description de_sgm
                       , DECODE (SUBSTR (a.compiled_value_attributes, 5, 1)
                               , 'L', 'Passivo'
                               , 'A', 'Ativo'
                               , 'E', 'Despesa'
                               , 'O', 'Pat.Liq'
                               , 'R', 'Receita')
                           tp_sgm
                    FROM fnd_flex_values_vl a, fnd_flex_values_tl b
                   WHERE a.flex_value_set_id = 1015237
                     AND a.flex_value_id = b.flex_value_id
                     AND b.language = 'PTB') cta
             , fnd_user fus
         WHERE gjl.je_header_id = gjh.je_header_id
           AND gjb.je_batch_id = gjh.je_batch_id
           AND gjs.je_source_name = gjh.je_source
           AND gjh.ledger_id = 2041
           AND gjh.actual_flag = 'A'
           AND gjh.period_name = '&&periodo' -- 'JAN-14'
           AND gcc.code_combination_id = gjl.code_combination_id
           AND gcc.segment1 IN ('01', '12', '13', '14', '05', '16', '18')
           AND emp.id_sgm = 'EMPRESA'
           AND emp.cd_sgm = gcc.segment1
           AND cta.id_sgm = 'CONTA'
           AND cta.cd_sgm = gcc.segment2
           AND fus.user_id = gjb.last_updated_by
          -- and rownum<1001;
                  
    spool off;
    
    

    I did something like that, when I turned it in a procedure...

    create or replace PROCEDURE       XXTVGAUDIT (o_return_err      OUT VARCHAR2
                                                  , o_return_code     OUT NUMBER
                                                  , p_period_name  IN     VARCHAR2
                                                  , p_nr_livro     IN     NUMBER)
    IS
      CURSOR c1
      IS
    SELECT
              rpad(SUBSTR (gcc.segment1, 1, 2),2,' ')
               || rpad(TRANSLATE (
                    CONVERT (
                    TRANSLATE (
                        REPLACE(REPLACE (REPLACE (SUBSTR (emp.de_sgm, 1, 70), CHR (13), ''), CHR (10), ''),CHR (9), '')
                       ,'??????????????????¡§©³º ¨¬²¹¢ª®´»£µ«¼!@#$%*()_+=[]{}/\?:<>|ãÃõÕçÇüÜâÂêÊôÔáÁàÀéÉíÍóÓúÚñшÞ'
                       ,'                                                             aAoOcCuUaAeEoOaAaAeEiIoOuUnN  ')
                   ,'US7ASCII'
                   ,'WE8ISO8859P1') ,'?',' '),70,' ')
               || rpad(SUBSTR (gjs.user_je_source_name, 1, 20),20,' ')
               || lpad(DECODE (NVL (gjl.entered_dr, 0)
                        , 0, DECODE (NVL (gjl.accounted_dr, 0), 0, 'C', 'D')
                        , 'D'),1,' ')
               || lpad(TO_CHAR (gjh.default_effective_date, 'DD-MON-YY'),9,' ')
               || lpad(TO_CHAR (gjh.posted_date, 'DD-MON-YY'),9,' ')
               || lpad(SUBSTR (gcc.segment2, 1, 9),9,' ')
               || rpad(TRANSLATE (
                    CONVERT (
                    TRANSLATE (
                        REPLACE(REPLACE (REPLACE (SUBSTR (cta.de_sgm, 1, 100), CHR (13), ''), CHR (10), ''),CHR (9), '')
                       ,'??????????????????¡§©³º ¨¬²¹¢ª®´»£µ«¼!@#$%*()_+=[]{}/\?:<>|ãÃõÕçÇüÜâÂêÊôÔáÁàÀéÉíÍóÓúÚñшÞ'
                       ,'                                                             aAoOcCuUaAeEoOaAaAeEiIoOuUnN  ')
                   ,'US7ASCII'
                   ,'WE8ISO8859P1') ,'?',' '),100,' ')
               || rpad(SUBSTR (cta.tp_sgm, 1, 10),10,' ')
               || lpad(TO_CHAR (NVL (gjl.accounted_dr, 0),'999G999G999G999G999G990D00'),38,' ')
               || lpad(TO_CHAR (NVL (gjl.accounted_cr, 0),'999G999G999G999G999G990D00'),38,' ')
               || lpad(SUBSTR (gjh.currency_code, 1, 5),5,' ')
               || rpad(TRANSLATE (
                    CONVERT (
                    TRANSLATE (
                        REPLACE(REPLACE (REPLACE (REPLACE (SUBSTR (gjl.description, 1, 150), '|', '@'), CHR (13), ''), CHR (10), ''),CHR (9), '')
                       ,'??????????????????¡§©³º ¨¬²¹¢ª®´»£µ«¼!@#$%*()_+=[]{}/\?:<>|ãÃõÕçÇüÜâÂêÊôÔáÁàÀéÉíÍóÓúÚñшÞ'
                       ,'                                                             aAoOcCuUaAeEoOaAaAeEiIoOuUnN  ')
                   ,'US7ASCII'
                   ,'WE8ISO8859P1') ,'?',' '),150,' ')
               || rpad(gjb.last_updated_by,15,' ')
               || rpad(TRANSLATE (
                    CONVERT (
                    TRANSLATE (
                        REPLACE(REPLACE (REPLACE (SUBSTR (gjb.name, 1, 100), CHR (13), ''), CHR (10), ''),CHR (9), '')
                       ,'??????????????????¡§©³º ¨¬²¹¢ª®´»£µ«¼!@#$%*()_+=[]{}/\?:<>|ãÃõÕçÇüÜâÂêÊôÔáÁàÀéÉíÍóÓúÚñшÞ'
                       ,'                                                             aAoOcCuUaAeEoOaAaAeEiIoOuUnN  ')
                   ,'US7ASCII'
                   ,'WE8ISO8859P1') ,'?',' '),100,' ')
               || lpad(SUBSTR (fus.user_name, 1, 30),30, ' ')
                 linha_utl
          FROM gl_je_lines gjl
             , gl_je_headers gjh
             , gl_code_combinations gcc
             , gl_je_sources gjs
             , gl_je_batches gjb
             , (SELECT 'EMPRESA' id_sgm
                     , a.flex_value cd_sgm
                     , b.description de_sgm
                     , DECODE (SUBSTR (a.compiled_value_attributes, 5, 1)
                             , 'L', 'Passivo'
                             , 'A', 'Ativo'
                             , 'E', 'Despesa'
                             , 'O', 'Pat.Liq'
                             , 'R', 'Receita')
                         tp_sgm
                  FROM fnd_flex_values_vl a, fnd_flex_values_tl b
                 WHERE a.flex_value_set_id = 1015197
                   AND a.flex_value_id = b.flex_value_id
                   AND b.language = 'PTB') emp
             , ( SELECT 'CONTA' id_sgm
                       , a.flex_value cd_sgm
                       , b.description de_sgm
                       , DECODE (SUBSTR (a.compiled_value_attributes, 5, 1)
                               , 'L', 'Passivo'
                               , 'A', 'Ativo'
                               , 'E', 'Despesa'
                               , 'O', 'Pat.Liq'
                               , 'R', 'Receita')
                           tp_sgm
                    FROM fnd_flex_values_vl a, fnd_flex_values_tl b
                   WHERE a.flex_value_set_id = 1015237
                     AND a.flex_value_id = b.flex_value_id
                     AND b.language = 'PTB') cta
             , fnd_user fus
         WHERE gjl.je_header_id = gjh.je_header_id
           AND gjb.je_batch_id = gjh.je_batch_id
           AND gjs.je_source_name = gjh.je_source
           AND gjh.ledger_id = 2041 -- p_nr_livro
           AND gjh.actual_flag = 'A'
           AND gjh.period_name = upper('null') -- 'JAN-14'
           AND gcc.code_combination_id = gjl.code_combination_id
           AND gcc.segment1 IN ('01', '12', '13', '14', '05', '16', '18')
           AND emp.id_sgm = 'EMPRESA'
           AND emp.cd_sgm = gcc.segment1
           AND cta.id_sgm = 'CONTA'
           AND cta.cd_sgm = gcc.segment2
           AND fus.user_id = gjb.last_updated_by
          AND rownum<1001;
          
      CURSOR c2
      IS
        SELECT /*+
             INDEX(GCC GL_CODE_COMBINATIONS_U1)
             INDEX(GJB GL_JE_BATCHES_U1)
             INDEX(FUS FND_USER_U1)
             INDEX(GJL GL_JE_LINES_U1)*/
                    (lpad(TO_CHAR (NVL (SUM(gjl.accounted_dr), 0),'999G999G999G999G999G990D00'),268,' ')) /*VL_DEBITO*/
             ||' '||(lpad(TO_CHAR (NVL (SUM(gjl.accounted_cr), 0),'999G999G999G999G999G990D00'),37 ,' ')) /*VL_CREDITO*/
             ||' '|| TO_CHAR (COUNT (*)) soma /*qtd_reg*/
          FROM gl_je_lines gjl
             , gl_je_headers gjh
             , gl_code_combinations gcc
             , gl_je_sources gjs
             , gl_je_batches gjb
             , (SELECT 'EMPRESA' id_sgm
                     , a.flex_value cd_sgm
                     , b.description de_sgm
                     , DECODE (SUBSTR (a.compiled_value_attributes, 5, 1)
                             , 'L', 'Passivo'
                             , 'A', 'Ativo'
                             , 'E', 'Despesa'
                             , 'O', 'Pat.Liq'
                             , 'R', 'Receita')
                         tp_sgm
                  FROM fnd_flex_values_vl a, fnd_flex_values_tl b
                 WHERE a.flex_value_set_id = 1015197
                   AND a.flex_value_id = b.flex_value_id
                   AND b.language = 'PTB') emp
             , ( SELECT 'CONTA' id_sgm
                       , a.flex_value cd_sgm
                       , b.description de_sgm
                       , DECODE (SUBSTR (a.compiled_value_attributes, 5, 1)
                               , 'L', 'Passivo'
                               , 'A', 'Ativo'
                               , 'E', 'Despesa'
                               , 'O', 'Pat.Liq'
                               , 'R', 'Receita')
                           tp_sgm
                    FROM fnd_flex_values_vl a, fnd_flex_values_tl b
                   WHERE a.flex_value_set_id = 1015237
                     AND a.flex_value_id = b.flex_value_id
                     AND b.language = 'PTB') cta
             , fnd_user fus
         WHERE gjl.je_header_id = gjh.je_header_id
           AND gjb.je_batch_id = gjh.je_batch_id
           AND gjs.je_source_name = gjh.je_source
           AND gjh.ledger_id = 2041
           AND gjh.actual_flag = 'A'
           AND gjh.period_name = 'null' -- 'JAN-14'
           AND gcc.code_combination_id = gjl.code_combination_id
           AND gcc.segment1 IN ('01', '12', '13', '14', '05', '16', '18')
           AND emp.id_sgm = 'EMPRESA'
           AND emp.cd_sgm = gcc.segment1
           AND cta.id_sgm = 'CONTA'
           AND cta.cd_sgm = gcc.segment2
           AND fus.user_id = gjb.last_updated_by
           
           and rownum<1001;
      w_ind_erro     NUMBER;
      w_erro_geral   EXCEPTION;
    
    
      w_msg_erro     VARCHAR2 (240);
      w_linha        VARCHAR2 (1000);
    
    
      w_nm_arq_utl   UTL_FILE.file_type;
      w_nm_arq_utl_r UTL_FILE.file_type;
    
    
      w_nm_dir_dad   VARCHAR2 (80);
      --w_nm_int_dir_dad VARCHAR2 (80);
      --w_nm_arq_dad   VARCHAR2 (80);
      w_nm_arq_dad_aux VARCHAR2 (80);
      w_nm_arq_dad_qtd VARCHAR2 (80);
      
      P_DIRETORIO VARCHAR2(200) := '/tmp';
      P_ARQUIVO   VARCHAR2(200) := 'Desliga_mainframe_indices_economicos.csv';
      
      W_DIRETORIO VARCHAR2(50) := P_DIRETORIO;
      W_ARQUIVO   VARCHAR2(50) := P_ARQUIVO;
    
    
      w_qtd_reg      NUMBER;
    
    
      -- -----------------------------------------------
    
      PROCEDURE pr_abre_txt --(p_nm_dir IN VARCHAR2, p_nm_arq IN VARCHAR2, p_tp_abertura IN VARCHAR2)
      IS
      BEGIN
        w_nm_arq_utl := UTL_FILE.fopen ( W_DIRETORIO, W_ARQUIVO, 'W');
      EXCEPTION
        WHEN UTL_FILE.invalid_path THEN
          UTL_FILE.fclose (w_nm_arq_utl);
          raise_application_error (-20504, 'ERRO NA ABERTURA DO ARQUIVO: Caminho Invalido');
        WHEN UTL_FILE.invalid_mode THEN
          UTL_FILE.fclose (w_nm_arq_utl);
          raise_application_error (-20504, 'ERRO NA ABERTURA DO ARQUIVO: Modo Invalido');
        WHEN UTL_FILE.invalid_filehandle THEN
          UTL_FILE.fclose (w_nm_arq_utl);
          raise_application_error (-20504, 'ERRO NA ABERTURA DO ARQUIVO: Nome Arquivo Invalido');
        WHEN UTL_FILE.invalid_operation THEN
          UTL_FILE.fclose (w_nm_arq_utl);
          raise_application_error (-20504, 'ERRO NA ABERTURA DO ARQUIVO: Operacao Invalida');
        WHEN UTL_FILE.read_error THEN
          UTL_FILE.fclose (w_nm_arq_utl);
          raise_application_error (-20504, 'ERRO NA ABERTURA DO ARQUIVO: Erro Leitura');
        WHEN UTL_FILE.write_error THEN
          UTL_FILE.fclose (w_nm_arq_utl);
          raise_application_error (-20504, 'ERRO NA ABERTURA DO ARQUIVO: Erro Escrita');
        WHEN UTL_FILE.internal_error THEN
          UTL_FILE.fclose (w_nm_arq_utl);
          raise_application_error (-20504, 'ERRO NA ABERTURA DO ARQUIVO: Erro Interno');
      END pr_abre_txt;
    
    
      -- ------------------------------------------------------
      PROCEDURE pr_grava_txt (p_de_msg IN VARCHAR2)
      IS
      BEGIN
        UTL_FILE.put_line (w_nm_arq_utl, p_de_msg);
      EXCEPTION
        WHEN UTL_FILE.invalid_path THEN
          raise_application_error (-20503, 'ERRO AO GRAVAR: Caminho Invalido');
        WHEN UTL_FILE.invalid_mode THEN
          raise_application_error (-20503, 'ERRO AO GRAVAR: Modo Invalido');
        WHEN UTL_FILE.invalid_filehandle THEN
          raise_application_error (-20503, 'ERRO AO GRAVAR: Nome Arquivo Invalido');
        WHEN UTL_FILE.invalid_operation THEN
          raise_application_error (-20503, 'ERRO AO GRAVAR: Operacao Invalida');
        WHEN UTL_FILE.read_error THEN
          raise_application_error (-20503, 'ERRO AO GRAVAR: Erro Leitura');
        WHEN UTL_FILE.write_error THEN
          raise_application_error (-20503, 'ERRO AO GRAVAR: Erro Escrita');
        WHEN UTL_FILE.internal_error THEN
          raise_application_error (-20503, 'ERRO AO GRAVAR: Erro Interno');
      END pr_grava_txt;
    
    
      -- ------------------------------------------------------
      PROCEDURE pr_fecha_txt
      IS
      BEGIN
        UTL_FILE.fclose (w_nm_arq_utl);
      EXCEPTION
        WHEN OTHERS THEN
          raise_application_error (-20501, 'ERRO NO FECHAMENTO ARQUIVO DE LOG');
      END pr_fecha_txt;
      -- --------------------------------------------------------------------------------------------------
      BEGIN
      --PR_ABRE_TXT (W_NM_DIR_SQL, W_NM_ARQ_DAD ,'w');
      pr_abre_txt ( W_DIRETORIO, W_ARQUIVO, 'w');
    
    
      w_nm_arq_utl_r := UTL_FILE.fopen ( w_nm_arq_utl, w_nm_arq_dad_qtd, 'w');
     -- w_qtd_reg   := 0;
    
    
     /* FOR cur2 IN c2
      LOOP
        w_linha     := cur2.soma;
        pr_grava_txt (w_linha);
    
    
        w_qtd_reg   := w_qtd_reg + 1;
    
    
        --IF MOD (w_qtd_reg, 100000) = 0 THEN
          UTL_FILE.put_line (w_nm_arq_utl_r, 'Qtd. de linhas geradas = ' w_qtd_reg w_linha );
        --END IF;
      END LOOP;
    
    
     -- UTL_FILE.put_line (w_nm_arq_utl_r, 'Final de Qtd. de linhas geradas = ' || w_qtd_reg);
      UTL_FILE.fclose (w_nm_arq_utl_r);
      --*/
      -- --------------------------------------------------------------------------------------------------
      pr_fecha_txt;
      --
      -- --------------------------------------------------------------------------------------------------
    
    
    
    
    
    
    EXCEPTION
      WHEN w_erro_geral THEN
        raise_application_error (-20501, 'Parada por motivo de Erros na execução.');
    --
    END XXTVGAUDIT;
    

    Oracle Directory object is not OS directory. It is a definition saying Oracle which OS directory to use. When Oracle run

    v_file: = UTL_FILE.fopen ('TMP_DIR', 'output.log', 'W');

    He goes to the data dictionary and:

    1. it checks the Oracle directory object exists tmp_dir

    2. If the Oracle user is allowed to create files on this object directory Oracle (see WRITING privilege granted I posted)

    3 reflects the object of Oracle TMP_DIR for OS directory/tmp directory

    4 creates the file /tmp/output.og owned by OS oracle user with the appropriate permissions on the database server (assuming that OS directory Oracle Directory object points on exists and oracle OS user can create files there).

    Remember, most of the time the OS Oracle user created files permissions are such that the 'others' can even read.

    SY.

  • error with utl_file for user... !

    SET OF BUFFER 1000000
    SET SERVEROUTPUT ON
    coil LMG_DBmigration_log.log
    Declare
    V_File UTL_FILE. TYPE_DE_FICHIER;
    V_Dir VARCHAR2 (4000);
    V_Filename VARCHAR2 (2000);
    BEGIN
    V_Dir: = "DATAMIGRATION";

    DBMS_OUTPUT. Put_line ('start...');

    v_filename: = 'LMG_DBmigration_out.txt ';
    V_File: = UTL_FILE. FOPEN (v_dir, v_filename, 'w');

    DBMS_OUTPUT. Put_line ("open file... '");

    UTL_FILE. Put_line (V_File, 'hey..');
    UTL_FILE. Put_line (V_File, 'I am pc...');

    UTL_FILE. FCLOSE (v_file);
    EXCEPTION
    WHILE OTHERS THEN
    DBMS_OUTPUT. Put_line ("an unexpected error: ' |") substr (SQLERRM, 1, 100));

    End;
    /

    spool off
    pause
    "exit";
    ------------------------------------------------------------------------------------------

    When running command, I get error like below...

    sqlplus co/co@LMGCO AS SYSDBA @Test_UTL.sql

    o/p-

    beginning...
    Unexpected error: ORA-29283: invalid file operation
    ORA-06512: at
    'SYS. UTL_FILE", line 488
    ORA-29283: invalid file ope

    PL/SQL procedure successfully completed.
    ------------------------------------------------------------------------------------------

    kindly help me, if there is no problem with the question of privilege user, then please erase me how to fix it...

    Published by: PC on November 26, 2010 05:56

    >
    Yes... "D:\test_co" exists in the local computer and I connect to another server with the help of tnsname.ora
    >
    This is the reason why you get the error message. Oracle search folder "D:\test_co" of the computer server database and not from your local computer.

    You must go to the "172.18.86.10" computer and see what records there. If necessary create a folder "\test_co" somewhere in this remote computer. Then your code wil lstart of work afterwards and folder is created on the remote computer, not on your local computer.

  • I converted a file for a friend from pdf to doctx; he receives this messgae when he tried to open the testament of file is not open, "invalid directory name.

    I converted a file for a friend from pdf to doctx; He received this message while trying to open the will of file is not open, "invalid directory name.

    Hi vasiliost69641524,

    This error is supposed to be linked with MS Word, please refer to this link directory name of the error invalid - Microsoft community.

    Kind regards

    Nicos

  • How to create files with UTL_FILE client-side?

    Hello

    I would like to be able to generate files in the client operating system, without making use of dbms_output, sql * more. I actually thought, it should be possible to do this task with UTL_FILE. See this link:

    http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28419/u_file.htm

    Read you: 'UTL_FILE provides access to both client-side and server-side files. When run on the server UTL_FILE gives access to all the operating system files that are accessible from the server. Client side, as is the case for Forms applications, UTL_FILE provides access to operating system files that are accessible from the client. »

    But I can't create a directory on the client side object... How is possible to write files on my client OS?

    Thanks in advance,

    Xenofon

    UTL_FILE is always executed on the database server side. Therefore, to create the file using UTL_FILE client-side you need to map/mount client drive on the database server and make sure that oracle user has appropriate access to him.

    SY.

  • ORA-29280: invalid directory path

    do face a problem,

    My requirement is I have to brought from a schema for a remote database my current schema some procedure, packages, functions scripts and compile them here in my current schema.
    Basically, straight word what I have to do is, all functions, procedures, are there packages in the remote schema (that I can access by a datbase link) must be created in my current schema.
    so I got what I was trying to make is just source codes to access all_sources and creating files in a code here directory.giving.

    First, what I've done is created an Oracle Directory.

    First I created a directory called "PROC_PKG_FUNC" in drive D, then I ran the following command.

    SQL > create directory 'PROC_PKG_FUNC' as 'D:\'PROC_PKG_FUNC ';
    Created directory.

    CREATE or REPLACE PROCEDURE Get_Db_Ddl_Scripts as
    v_file Utl_File.FILE_TYPE;
    v_file_dir VARCHAR2 (50);
    i_first_line NUMBER: = 1;
    BEGIN

    v_file_dir: = 'PROC_PKG_FUNC ';

    FOR REC_OBJ IN
    (SELECT a DISTINCT NAME, TYPE, DECODE (TYPE, 'FUNCTION', 'FUNCTIONS', 'PACKAGE', "PACKAGES", "PACKAGE BODY ', 'PACKAGES_BODY'," PROCEDURE", 'PROCEDURES', 'TYPE', 'TYPE', 'TYPE BODY', 'TYPES_BODY') v_file_dir)
    FROM ALL_SOURCE@FRISKDEVI41B_ORCL WHERE OWNER = 'FRISKDEVI41B. '
    AND TYPE IN ('FUNCTION, PROCEDURE, 'PACKAGE', 'PACKAGE BODY', 'TYPE'))
    LOOP
    v_file: = Utl_File.FOPEN (card = > REC_OBJ.v_file_dir,)
    filename = > REC_OBJ.NAME | ".sql",.
    OPEN_MODE = > 'w ',.
    max_linesize = > 32767);
    i_first_line: = 1;
    FOR REC IN (SELECT TEXT FROM ALL_SOURCE@FRISKDEVI41B_ORCL WHERE NAME = REC_OBJ.NAME AND TYPE = REC_OBJ. TYPE AND OWNER = 'FRISKDEVI41B' ORDER BY LINE)
    LOOP
    IF i_first_line = 1 THEN
    Utl_File.put_line (v_file, "CREATE or REPLACE" |) REPLACE (REC. TEXT, CHR (10), NULL));
    ELSE Utl_File.PUT_LINE (v_file, REPLACE (REC. TEXT, CHR (10), NULL));
    END IF;
    i_first_line: = i_first_line + 1;
    END LOOP;
    Utl_File.FCLOSE (v_file);

    END LOOP;

    END;
    /


    but when I try to run this am getting error,
    ORA-29280: invalid directory path
    ORA-06512: at "SYS." UTL_FILE", line 33
    ORA-06512: at "SYS." UTL_FILE", line 436
    ORA-06512: at "SYS." GET_DB_DDL_SCRIPTS', line 15
    ORA-06512: at line 2

    I know probbaly get this error because I am trying to create different directories, just like functions packages etc. under the external using this loop recording repertoire, but how would it be possible, please help.

    Kind regards
    Manuella

    In oracle when you say that CREATE or REPLACE the DIRECTORY you do not create a directory in the operating system, you simply create a reference to the directory in the operating system.

    So I don't know what you're asking.

  • Get the filename with utl_file package

    Hello

    I'm running on oracle version 10.2.0.3.0.
    Are there opportunities scan the oracle Center and get all the file names in plsql table using the utl_file package?


    Thank you!

    Cann't do you with UTL_file, you use java or other external language. as

    create or replace type List as table of   varchar2(255);
    /
    
    create or replace and compile java source named "FileList"
    as
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    
    public class FileList
    {
       public static ARRAY getList(String directory) throws SQLException
       {
           File path = new File( directory );
           Connection conn =
                 new OracleDriver().defaultConnection();
           ArrayDescriptor descriptor =
             ArrayDescriptor.createDescriptor( "LIST", conn );
           return new ARRAY( descriptor, conn, path.list() );
       }
    }
    /
    
    CREATE OR REPLACE FUNCTION  GETFILES_FUN( DIR_PATH_V VARCHAR2)   return List
    AS language java name 'FileList.getList(java.lang.String )
              return oracle.sql.ARRAY.ARRAY';
    /  
    
    select *     from TABLE ( cast (GETFILES_FUN( 'c:\\' ) as List) );
    

    Concerning
    Singh

  • Blue square with a question mark instead of a picture

    I'm on Messages to use with your Mac - Apple Support.

    Instead of pictures (or), I get a blue square with a question mark in it.

    This does not happen with all Web sites, but I wonder why it's happening with an Apple site, and how I can see the photos.

    It sounds like a broken image link.

    Post a screenshot if you can, so that we can confirm. The page seems OK after a glance. Command + shift + 4 then do slide on the affected area, add the image to the desktop to this site via the camera icon.

    If you have browser extensions, disable them and repeat the test. Also try a different web browser if possible to see if it is the scale of the system or only Safari. Is - this Safari you use?

  • What is the yellow square with a question mark on the page OPTIONS of FireFox? Have a peak.

    There is a yellow square with a question mark on the FireFox OPTIONS / settings page.
    If the mouse enters it, it reacts like it is something to click, but no indication that it is.
    Is it supposed to be there and if so, why?
    He has a POINT of MARK BLACK inside the small SQUARE of YELLOW.
    Any help is appreciated.

    This is the help screen. Press the key.

  • In support, forum, signed in, where can I associate with the questions I ask myself? Years back, could get the RSS feed for the question. Always available?

    Where can I associate with my questions about my account? The search for user name does not work. A few years back, you could subscribe to an RSS feed for a question, yours or others. Is - this past, if so, why? How can you save the question, without saving your question text in a document and copy and paste into search? Version of FF 19.0.2.

    Thank you.

    Your messages will now appear in your profile: https://support.mozilla.org/en-US/user/225440

    You can also use the old method of "My Contributions" link: https://support.mozilla.org/questions?filter=my-contributions

    Is that it?

  • Mac Pro does not.  It has a box with a question mark?

    My Mac Pro has stopped working all of a sudden.  We stop for the night and the next day, we got a box with a question mark?  Any ideas?

    Hope this helps.

    OS X: on OS X Recovery - Apple Support

  • I get a folder with a question mark symbol when I turn on

    I'm giving my daughter my MacBook Pro retina (2013) so I'll try to get it to the factory settings.  I tried reloading ElCapitan and downloaded for half an hour and then says that the download failed.  This happened twice, and now all I get is a folder with a question mark symbol.  What should I do?

    Hey! Take a look at these articles Support from Apple and try basic troubleshooting steps.

    If a flashing question mark appears when you start your Mac - Apple Support

    On the screens, you see when you start your Mac - Apple Support

  • Safari on my MacBook Pro retina 9.0.3 15-inch Version 10.11.3 do not show images on some Internet sites. They appear for a fraction of a second then disappear with a question mark in the Center. The same sites work fine on Chrome and Firefox.

    Safari on my MacBook Pro retina 9.0.3 15-inch Version 10.11.3 do not show images on some Internet sites. They appear for a fraction of a second then disappear with a question mark in the Center. The same sites work fine on Chrome and Firefox.

    I suggest you only begin by taking the measures recommended in this support article.

  • How to protect a directory with password in windows XP?

    How to protect a directory with password in windows XP?

    XP does not use passwords to protect resources. NT operating systems use the permissions. Here's the information to help you with that:

    How to disable Simple Sharing and set permissions on a folder shared in Windows XP (Pro only)
    http://support.Microsoft.com/?kbid=307874

    How to configure file sharing in Windows XP (includes information about permissions):
    http://support.Microsoft.com/kb/304040

    By default in XP Home you can only files and folders under My Documents "private". Otherwise, to display the Security tab in Windows XP Home, restart in safe mode and log on with an account that has administrator privileges. Go in Safe Mode, press the F8 key as the computer starts. That you will get the menu where you can choose Safe Mode.

    Note that the file system must be NTFS, FAT32 not.

    Passwording of folders is not possible unless you their zip. When you do (right click on a folder, then "send to > compressed folder") and then open the zip file, you will find an option under file > "add a password." Otherwise, use a third-party software. Google "password protect folders".
    MS - MVP - Elephant Boy computers - don't panic!

Maybe you are looking for