problem with utl_file

Dear all,

Oracle Version: 10.2.0.5.0

I am trying to create a folder for the utl_fil utility to export the data with the following options

create or replace directory utl_file_dir as ' / tmp'


I do not have see the/tmp file is created, could you please suggest if I do something wrong.

where the 'tmp' file, will be created is in the C drive?

Abhishek

Directory is Oracle as a pointer. It points to a directory of the operating system.

If your statement

create or replace directory utl_file_dir as ' / tmp'

Creates a directory object that points to an OS/tmp directory. Oracle does not validate the existence of the OS directory when creating the directory object.

So now you must issue a command to OS level to create a physical directory. For example, on Unix you can do this

mkdir/tmp

This will create a tmp directory in the OS.

Tags: Database

Similar Questions

  • 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.

  • problem with the CLOB type

    Hello, I am a beginner, I have a problem with the CLOB type, please help me
    I want to write the input file is filename and string base64, then output decoded base64 content in dicrectory location (for example C:\),my code was executed but if entry with base64 long string, it displays error)
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 136
    ORA-06512: at "SYS.UTL_FILE", line 813
    ORA-06512: at "SYSTEM.WRITED", line 9
    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.
    And this is my code
    create or replace directory dir_temp as 'C:\';
    /
    create or replace procedure writed(filename varchar2,code  clob)
    as
      f utl_file.file_type;
      v_lob          BLOB;  
    
    begin
      v_lob :=  UTL_ENCODE.BASE64_DECODE( UTL_RAW.CAST_TO_RAW(to_char(code)) ); 
      f := utl_file.fopen('DIR_TEMP', filename, 'w');
      utl_file.put_line(f,to_clob(utl_raw.cast_to_varchar2(v_lob)));  
      utl_file.fclose(f); 
    end;
    Thank you
    DBMS_XSLPROCESSOR.clob2file(
      cl => l_clob
    , flocation => 'XML_LOG'
    , fname => myfile_name
    );
    

    for example

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    type t_emps is table of emp%ROWTYPE;
      3    v_emps    t_emps;
      4    --
      5    v_clob    clob;
      6    v_newline varchar2(2) := chr(13)||chr(10);
      7  begin
      8    -- get the rows into a PL/SQL collection of records
      9    select *
     10    bulk collect into v_emps
     11    from emp;
     12    -- build up the CLOB
     13    v_clob := 'EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO';
     14    for i in 1..v_emps.count
     15    loop
     16      v_clob := v_clob||v_newline||
     17                to_char(v_emps(i).empno,'fm9999')||','||
     18                v_emps(i).ename||','||
     19                v_emps(i).job||','||
     20                to_char(v_emps(i).mgr,'fm9999')||','||
     21                to_char(v_emps(i).hiredate,'YYYYMMDD')||','||
     22                to_char(v_emps(i).sal,'fm99999')||','||
     23                to_char(v_emps(i).comm,'fm99999')||','||
     24                to_char(v_emps(i).deptno,'fm99');
     25    end loop;
     26    -- write the CLOB to a file
     27    DBMS_XSLPROCESSOR.clob2file(cl => v_clob, flocation => 'TEST_DIR', fname => 'myfile.csv');
     28* end;
    SQL> / 
    
    PL/SQL procedure successfully completed.
    
  • 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.

  • 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.

  • Read and write with UTL_FILE

    Hello
    I have a problem with a procedure I wrote... in this procedure I have to read the form a text file compare it with the data in the table and the lines which sastify the conditions must be written ito a new text file

    CODE
    ----------
    declare
    v_path varchar2 (50): = ' / dev/iodata;
    v_filename varchar2 (50): = 'Text1.txt ';
    p_dir varchar2 (50): = ' / dev/iodata;
    p_filename varchar2 (50): = "Text2.txt";
    v_input_file utl_file.file_type;
    p_output_file utl_file.file_type;
    cursor C1 is select id, value, Org chem;
    v_input_buffer varchar2 (500);
    p_output_buffer varchar2 (500);
    v_id Varchar2 (20);

    Start
    v_input_file: = utl_file.fopen (v_path, v_filename, 'R');

    p_output_file: = utl_file.fopen (p_dir, p_filename, 'w');

    Loop

    UTL_FILE.get_line (v_input_file, v_input_buffer);

    v_id: = LTRIM (RTRIM (substr (v_input_buffer, 1, 12)));
    DBMS_OUTPUT. Put_line (v_input_buffer);

    I'm in C1

    loop

    If i.id = v_id

    then
    p_output_buffer: = i.id | ' ' || i.Value | ' ' || i.Chem;
    DBMS_OUTPUT. Put_line (p_output_buffer);

    UTL_FILE.put_line (p_output_file, p_output_buffer);
    DBMS_OUTPUT. PUT_LINE('***');
    end if;

    end loop;

    UTL_FILE.fclose (p_output_file);

    End loop;

    exception
    When no_data_found then
    UTL_FILE.fclose (v_input_file);

    end;

    * all DBMS_OUTPUT_LINE are used for debug purpose

    OUTPUT
    -------------------
    00002010502 1
    00002010502 1
    ******
    00002010504 1
    00002010504 1
    declare
    *
    ERROR on line 1:
    ORA-29282: invalid file ID
    ORA-06512: at "SYS." UTL_FILE", line 774
    ORA-06512: at line 35

    Text1.txt have 2 lines, as you can see v_input_buffer bed that is to say the file is opened and read
    The for loop compares the i.id v_id and also burn some Text2.txt when I check the file writing
    BUT when it trys to write second line I am getting eroor... its not write and throw error

    I added all UTIL_FILE exceptions to my code and concluded that the exception as
    ERROR on line 1:
    ORA-20053: invalid file descriptor
    and now, I'm not able to determine how to handle this error... Please let me know how do slove this error...

    Thank you!

    Ok. So, let's think about how to add that.

    You've read online from the source file. You will need to extract one or more columns of this buffer (I'll assume that ID is a primary key, so you only need to extract the key)
    Then, you will need run a query on the ORG table with this extracted key, i.e.

    SELECT id || ', ' || value || ',' || chem
      INTO w_buffer
      FROM org
     WHERE id = <>
    

    And then, you will write the buffer to the file as usual.

    If you were to lets you read data from external tables, you can eliminate all UTL_FILE calls to read data and just attach the source to the ORG table file, i.e.

    <>
    FOR x IN (SELECT o.id, o.value, o.chem
                FROM org o,
                     source_file s
               WHERE o.id = s.id)
    LOOP
      <>
    END LOOP;
    <>
    

    Justin

  • problems with, phone, 6, Bluetooth kit, Nissan, after update, for, Rios, 1.0.2

    After the update to ios 10.0.2 - trying to use bluetooth to call my vehicle, it says: "this article is not in your phone book." How can I solve this problem?

    Greetings, joybelino1!

    Thank you for joining the communities Support from Apple! I can't wait to see that you are having problems with your Bluetooth in your car! The good news is that Apple has a great article that will help you with measures to try to resolve the problem. Read this article to gethelp to connect your iPhone, iPad, or iPod touch with your car radio. Even though he talks about problems with the connection, it also has the steps for other questions you may have once connected.

    If you use Bluetooth

    1. Consult the user manual of your car stereo to get the procedure to a Bluetooth device.
    2. On your iOS device, drag up to open Control Center, then press ontwice to turn on Bluetooth and turn it back on.
    3. Restart your iOS device.
    4. On your iOS device, Cancel the twinning of your car radio. On the screen of your car désapparier your iOS device and any other device. Restart your car and your iOS device, then pair and connect again.
    5. Update your iOS device.
    6. Install the updates to the firmware of your car radio.
    7. If you still not connect, contact Apple technical support.

    Have a great day!

  • Anyone having problems with WiFi connectivity after upgrade to Sierra?

    I was wondering if anyone else knows issues with WiFi connectivity since the upgrade to Sierra 10.12? I have not had any problems with connectivity WiFi previously on El Capitan. Now I have regular randomly loose connectivity. My internet is cable and when it is connected I have a 100% connection. My details of iMac and I have used only 10% of my storage.

    No problem with my iphone 6.

    Hello AspDesigns,

    I understand that, since the upgrade to Mac OS Sierra, your Mac seems to have trouble staying connected to Wi - Fi. Fortunately the diagnosis built-in wireless can help identify the source of so much trouble.

    Search for Wi - Fi using your Mac problems

    See you soon!

  • Problems with mail after switching to macOS Sierra

    Hey all

    After having recently upgraded to macOS Sierra, I am unable to read my mail.

    I get the following error every time I check on "Get Mail".

    There may be a problem with the mail server or the network. Check the account settings "*" or try again.

    The server returned the error: Mail could not connect to the server 'pop1.tribcsp.com' using SSL on the default ports. Verify that this server supports SSL and that your account settings are correct.

    What does this error message mean and how can I solve this problem.

    Thank you

    Hi Michael,

    I see your message that you get an error in the mail indicating that there is a problem with the mail server or the network.  To help get this problem resolved, I suggest that you follow the steps below:

    If mail refers to a problem with the mail server, or the network

    Mail will say that it is impossible to connect due to a problem with the mail server or the network. For example, the message may refer to a connection that has expired, or too many simultaneous connections:

    If you are connected to the Internet, but the connection has expired, your email provider might be affected by a discontinuance of service. Contact them or see their status Web page to ensure that their e-mail service is online. Examples of status pages:

    If the message indicates the number of simultaneous connections, too many of your devices is check your e-mail account at the same time. Quit Mail on one or more of your other devices.

    If you are still unable to send or receive e-mails

    1. Make sure that you have installed latest version of the Mac software updates, especially if the problem occurred immediately after the installation of a previous update.
    2. In OS X El Capitan or later version, you can see a status icon and the short error message in the upper right of the Mail window, under the search box. The message may indicate 'Network offline' or 'Connection failed', for example. Click the message to see more details on the issue.
    3. Check your connection to the Mail connection doctor. It might be able to say more on the issue.

    If you cannot send or receive e-mail on your Mac.

    Take care.

  • iMac 27 "mid-2011 - Intermittent problem with CPU fan running at full speed and sleep mode.

    Hello!

    My iMac 27 "has an intermittent problem with the CPU fan runs at full speed. Sometimes it happens at the time when I start it, sometimes only in my session, and sometimes only after a certain time. So does seem to be a problem of "heating".

    Second issue is with the mode 'sleep'. It may occur also at any time, at the start of the iMac, session, or after a certain time. But once he starts to go in mode 'sleep', when I wake up, it goes right back in mode after a few seconds and that it will continue indefinitely until I restart the computer.

    What could be?

    Please help me!

    4ntoine

    Here is my model of iMac:

    iMac 27 "mid-2011 model 12.2

    Intel Core i7 3.4 GHz

    AMD Radeon HD 6970M 1024 MB

    OS X El Capitan 10.11.6
    SMC 1.72f2

    Boot ROM IM121.0047.B23

    reset the SMC

    Reset the management system (SCM) controller on your Mac - Apple Support

  • problem with playing the clash of clans

    I'm having some problems while playing the clash of clans on my 2 mini ipad screen does not seem to meet sometimes as if it was some sort of delay so I have to tap several times in order to use a filter or throw the troops on the battlefield.

    Hi Trinitygr,

    Thanks for posting in the Community Support from Apple! I understand that you are having problems with your iPad screen while playing a game. I like to play games on my iPad and I don't see how this could be a nuisance. I'm happy to offer assistance.

    Are you only had this problem when using the app clash of Clans, or does it happen in all applications? I recommend to start by following the steps described in this article:
    If an application you have installed unexpectedly closes, unresponsive, or does not open

    Take care!

  • I'm having problems with an outdated Apple ID

    I have problems with updating Apps etc in my Apple account because he always asked an obsolete in sign.  How can I change this?

    Hello

    Go down to itunes apple ID Delete page homepage all ID and then add it back back.

    See you soon

    Brian

  • Anyone having problems with the new iPhone LTE connection 7 on Verizon?

    I am now on my iPhone second 7 with Verizon. I had four phones for me and my family. I have now had issues where I have no signal in the same areas where my signal allows to be strong. I can't solve the problem with the activation/deactivation of the airplane and then mode again in normal mode. My phone will rest with no signal for 5 minutes, then going to LTE with three bars. I also had the problem where I had only 1 x signal, while my son standing right next to me has LTE. And he had the same questions, where I'm on LTE and it gets no signal. I use to have LTE where I live and work all the time, now it's spotty at best. Apple has replaced me and my sons iPhones but not luck. Still do. Any ideas or an any other suffering?

    (1) go to settings/cell phone/cellular data Options/enable LTE and select ONLY the DATA. This seems to solve the problem (as a temporary solution) for most of the people affected by this problem. The bad part is your request might not be as clear (since they cannot use the highest LTE signals) and you can make calls and data at the same time. But it does not solve the issue.

    (2) there are rumors (but you didn't hear that from me that we only are not supposed to discuss beta software program Apple in this forum) that the new version of Apple Beta for iOS (which also includes an update of the software carrier Verizon to 26.0) seems to solve this problem. So, there's a light at the end of the tunnel.

  • Problem with some fonts of symbols after the installation of the Sierra

    Hello

    I have recently upgraded the OS on my iMac late 2012 for Sierra, since doing so, I noticed a problem with several fonts.

    All symbolic symbols Apple to Wingdings fonts not correctly displayed in the font book. Apple symbols looks like a standard wheelbase of san, and other symbolic fonts just show as question marks '?' where the images should be.

    In text editing, that I can't even see the symbolic fonts like Zapf Dingbats and Wingdings in the selector. However, they all work well in Adobe Illustrator (CS5) and Microsoft Word 2011. Apple symbols still looks like a standard font.

    I already tried the following:

    1. check the fonts in font book

    2 fix the duplicates in the font book

    3. using the "Restore Standard fonts" option in the font book

    4 deleting a file in the folder Preferences plist Fonts

    5 deleted the cache of police and the database

    I'm out of ideas. Has anyone else had the same problem found a fix?

    Kind regards

    Greville

    I'm just to add that I used the recovery partition to do a clean install of Sierra on a hard drive external and then booted into it to see if it had the same problem.

    And he does. Wingdings and other photo fonts appear as '?' in boxes where the letters must be in the font book.

    So this seems like a problem with the way Sierra displays these fonts, not with the font files themselves.

  • ios10 problem with non-users of iphone messaging

    After upgrading my iPhone 6 ios10, I had intermittent problems with the messaging of Android users (basically, the conversations no iMessage). In about 60% of the time it is not just to deliver the message no matter what I do (pressing the 'Try Again' don't work do not). He has no problem with the reception of the texts, but I can't answer to Android users (Interestingly, I can message users of Android if they are in a group with iPhone users text). I tried everything was updated to the last verision until reset of ios everything.

    I can't find anything online about this. I'm the only one who what?

    Group Messaging uses the MMS. Normal text messages using SMS. SMS uses the voice channel to transfer messages and is strictly a basic function. If you are experiencing problems sending SMS, contact your carrier.

Maybe you are looking for

  • Qosmio F20-136: I have no restore CD?

    The Qosmio F20-136 laptop comes with a Windows CD I can't find one, don't know if its just on the recovery CD, but I think remember me there used to be a Microsoft Map with etc product key, I do not see to be able to find a.Thank you

  • I bought an azatom docking station but could not find an adapter to work with my old than i Pod

    I bought an Azatom docking station but but it does not work with my 1st generation I Pod is there an adapter for it

  • Windows 7 vs windows Vista

    I think that the windows 7 everything is stupid, it is just like windows vista only better, but looks almost that much so I don't think that thay should in fact windows 7 a operating system, I think it should have been an update of windows vista. so

  • Inspiron 14 7000 series Subwoofer

    Hello This model has a built in subwoofer. The only way works the subwoofer is if I get the default speaker but then the normal speakers do not work. is not the box that is supposed to work with normal speakers?

  • Windows 2003 Server license

    We have Windows 2003 SBS STD DCAL with Cal user = 60 Qty. I would check if it covers Windows 2003 server user cal OR I have to buy windows user cal server separately. Appreciate your help