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.

Tags: Database

Similar Questions

  • Is there a way to color the correct main items that allows me to export/save the results as a mp4?

    Is there a way to color the correct main items that allows me to export/save the results as a mp4?  I shot images that I need to spend on another editor for editing, but I want to fix the images colors before putting to sea.  I know you can color correct elements, but is it possible to export the clips to the original position of the source for mp4?  I tried to export a clip using H.264 corresponds to the source, but the result is a half the size of the original file. Your help is appreciated!

    You realize that what you do is a generational loss.  Compression of the images already well compressed!... as well as many other works that used saw the final cut.

    Increase the flow of your export to preserve quality as much as possible.

  • After you generate a table in xml format, how can I save the result in an XML table?

    Hi all
    I used this feature to create a table in the XML schema:
    example:
    SELECT xmlelement ("State", xmlattributes (http://www.opengis.net/gml as "xmlns:gml"),)
    XMLFOREST (name as "Name", "Population" of the population)) of the State;
    result:
    < Statexmlns:gml = "http://www.opengis.net/gml" >
    < name > Wilkopolska < / name >
    the population of 35000 <>< / Population >
    < / state >
    Now I need to insert the result in an XML table, because I need to save the result to use the latter, I hope someone can help, and if there is other way to do this, it would be great.
    Thanks an ot and best regards,
    Lama.

    Just insert in a table...

    insert into t
    SELECT xmlelement("State", xmlattributes( 'http://www.opengis.net/gml' as "xmlns:gml"),
    xmlforest(name as "Name", population as "Population")) from state; 
    

    and a complete example:

    SQL> create table t (test xmltype)
      2  /
    
    Table created.
    
    SQL>
    SQL> create table state
      2  (name varchar2(10)
      3  ,population number
      4  )
      5  /
    
    Table created.
    
    SQL>
    SQL> insert into state values ('WI', 35000)
      2  /
    
    1 row created.
    
    SQL>
    SQL> SELECT xmlelement("State", xmlattributes( 'http://www.opengis.net/gml' as "xmlns:gml"),
      2  xmlforest(name as "Name", population as "Population")) from state; 
    
    XMLELEMENT("STATE",XMLATTRIBUTES('HTTP://WWW.OPENGIS.NET/GML'AS"XMLNS:GML"),XMLFOREST(NAMEAS"NAME",P
    ----------------------------------------------------------------------------------------------------
    WI35000
    SQL>
    SQL> insert into t
      2  SELECT xmlelement("State", xmlattributes( 'http://www.opengis.net/gml' as "xmlns:gml"),
      3  xmlforest(name as "Name", population as "Population")) from state; 
    
    1 row created.
    
    SQL> select *
      2    from t
      3  /
    
    TEST
    ----------------------------------------------------------------------------------------------------
    WI35000
    
  • take screenshot and saves the image to a PNG file

    Hello

    How do I take screenshot and save the image as a PNG file?

    Thank you

    Avivit.

    If you want a picture of façade one VI, you can use the method to obtain images of Panel (or the Tool of Capture of Code, which offers a range of screws for this).

    If you want a picture of the entire screen, you can simulate a button on the print screen, using the method of Clipboard.Get Image Application class to get a picture of the contents of the Clipboard. If you are looking for "screenshot" you should probably find a few examples already.

  • On a list of Fund cheque images, FF wants to save the resulting .cgi file...

    instead of display the resulting image in the web browser. If I save the .cgi script resulting, I can run and display an image of the cheque.

    Chrome displays correctly the resulting image of the cgi script is returned.

    This can happen if a certain way the GET data (? xxx = xxx) which is needs to be evaluated by the CGI script is lost.

    Clear the cache and cookies from sites that cause problems.

    "Clear the Cache":

    • Edit > Preferences > advanced > network > storage (Cache) offline: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Edit > Preferences > privacy > Cookies: "show the Cookies".

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions of the origin of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • Save the result of the functions of the MDGS in the table

    I build a model like the k-way clustering in the MDGS. I need to record number of cluster in the table. How can I?
    and then I put this building to automatically run all week?

    If you want to store the results in a table, create a node 'Create table '. To connect to the cluster use the node to the node "Create table". Be sure to include the PK attribute in the output, in addition to the attributes created by the algorithm of clusters. Then all you need will be in the table.

    If you click right on the node to apply it there is an option to deploy on the menu drop down. Select this option and save it to the Clipboard. Open something like Notepad and paste. You will get the code necessary to run the cluster. You will need to make some changes to this code to make it work automatically.

    I have a couple of posts on Clustering and a little more to come in the coming weeks. Discover them at the
    http://brendantierneydatamining.blogspot.IE/

  • How to save the results of a questionnaire analysis offline, without any LMS?

    Hello!

    And a happy new year!

    I am preparing a questionnaire to analyze the level of practice for my students, but the event is placed in the classroom, not online.

    I have not any LMS, therefore, at the end of the test, the results disappear...

    I need to save them, individually. I wanted to choose the Pdf version for this reason. But when I save the pdf file, after the test, all the student responses are blown away...

    Could you help me, please

    Thank you very much

    Nicoolfly

    In order to capture the scoring of results for later analysis, you really need a system that is an LMS or something similar.  Captivate has no functionality by default to give you that other system.  You can choose from the publication options based on the system to that you need the release.  PDF of Captivate output using addition to limit your options, because it is basically a document format, not a system designed to capture, store or send data.

    Have what method you had in mind to record the results of your students?

  • Problems with separation of the results in different lines. Group question?

    Hi all!

    I have a table that looks a bit like this:
    Pallet          Status          Number          Time
    A          MoveIn          48          11:11
    A          Pick          -1          11:11
    A          Pick          -1          11:12
    A          Pick          -1          11:12
    A          MoveOut     45          11:13
    A          MoveIn          45          18:20
    A          Pick          -1          18:23
    A          Pick          -1          18:23
    A          Pick          -1          18:23
    A          Pick          -1          18:24
    A          MoveOut     41          18:25
    A          MoveIn          41          21:31
    A          Pick          -1          21:55
    .....
    It's exploitation forest pallets that is moved to a station and then number of boxes is picked off the coast. (To make it more simple, I only show a palette in above example.)

    I would like to introduce the result with one row for each time that the palette were at the station, as:
    Pallet          Picked          Time
    A          3          11:11
    A          5          18:20
    A          ....          .....
    This means that the same palette can be showned on several lines, as happened to the station several times. I tried several different 'GROUP BY', but I can't get it to work.
    For example, I tried to group by time, but this fails if a pallet is moved twice per hour or if the boxes are picket at different times (for example, first box picked 09:59, last box 10:01)

    Anyone has a suggestion how to fix this problem?

    Thanks in advance and greetings / Anders from Sweden

    Hej, Anders,

    Can you explain what defines a group?

    Looks like you say that a group is a subset of a palette. If we organize all the lines for a palette in the order of time, a new group starts whenever we have a line where status = 'MoveIn. In other words, a group consists of a line with status = "MoveIn" and all the lines immediately after, in order by time, up to, but not including, the next row with status =-"MoveIn. Is this fair?

    If so, you can use the function COUNT (or SUM) Analytics to see how many lines with status = "MoveIn" have already taken place, in order by time, like this:

    WITH     got_grp          AS
    (
         SELECT     pallet, status, time
         ,     COUNT ( CASE
                             WHEN  status = 'MoveIn'
                       THEN  1
                         END
                    ) OVER ( PARTITION BY  pallet
                                ORDER BY          time
                        )           AS grp
         FROM    table_x
    )
    SELECT       pallet
    ,       COUNT ( CASE
                      WHEN  status = 'Pick'
                    THEN  1
                  END
                )          AS picked
    ,       MIN (time)          AS start_time
    FROM       got_grp
    GROUP BY  pallet
    ,            grp
    ORDER BY  pallet
    ,            grp
    ;
    

    If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

    This assumes that the combination (palette, time) is unique. Your sample data includes:

    Pallet          Status          Number          Time
    A          MoveIn          48          11:11
    A          Pick          -1          11:11
    

    I suppose that you decide to simply not show the full time, and your data is really something like:

    Pallet          Status          Number          Time
    A          MoveIn          48          23-Sep-2011 11:11:01
    A          Pick          -1          23-Sep-2011 11:11:08
    

    Otherwise, how do you know if these two lines are in you the same group or not? You may need to add a break to the analytical ORDER BY clause. For example, if you say "ORDER BY time, * status *", then, if the above two lines really have exactly the same time, to the second, then one with status = "MoveIn" would be considered as prior to the line with status = 'Choose'. "

  • Save the results locally when the database is offline

    Hello world!

    I work to justify the implementation of teststand for automation of test on the company where I work, far it seems that is the way to go, but they are some of the senior management, hesitating on this subject. One of the things that will be great for us (he will give him a +) is the ability to store the results locally on the workstation, where the database is offline (failure of the server or client disconnected from the network), and once he returns, the data is transferred to the database.

    We want to use SQL server for the database. I thought creating a SQL Server express locally on the computer, so all of the results will always be saved in the station first, I tried to use the sql import/export wizard to import data from a sql server to another, but I did not find any way to do it automatically, we are looking for one of the solution of the box free of charge or regular very very cheap It will be installed on each workstation.

    Thanks for your help and congratulations!

    Abelino,

    You can take advantage of the new features in later versions of TestStand.  In 2012, and most recent, you can write raw results.  As said Dennis you could just always write raw results.  Then use the TestStand Offline results new treatment utility write those in the database: http://zone.ni.com/reference/en-XX/help/370052K-01/tsref/infotopics/offline_processing_utility/

    You can create a service or something to do.

    BTW - Plugins can run in its own thread.

  • How can I achieve a sous-suite with Csharp for the results of the stage

    Hello

    I want to join a sous-suite programmatically. I used CSharp just in order to get the results of step, is not to create an execution. I start my run in TestStand. And in the Group of the cleanup step, I added a step to the 'Action' to collect the results, which will be used in another platform, of TestStand.

    To do this, I wrote the following code:

    Hey Ebru,

    Sous-Suite results are actually stored in their own container resultlist in TS. Sequencecall, which is accessible through the following statement:

    Locals.ResultList [step]. TS. SequenceCall.ResultList

    which step is the index of the call sequence step. This resultlist is structured in the same way as the table main resultList. You can also access your sous-suite directly from the container of movie file if it's in the same sequence as the main sequence file.  Access this reference using the following:

    RunState.SequenceFile.Data.Seq [sequenceName]

    Using this reference, you can access the result of each step Molok containers.

    I hope this helps!

  • Command chain vmkping all script and return results in a txt file

    Hi guys, hope you all are doing it very well?

    Does anyone know if there is a way I can put this together?

    What I'm trying to do here is to circumvent the tedious process of ping every IP configured for my target iSCSI through each VMK of each host.

    So basically I want some advice from you guys for what I can basically get this in a script.

    vmkping - I vmk1 10.0.0.10

    vmkping - I vmk2 10.0.0.10

    vmkping - I vmk3 10.0.0.10

    vmkping - I vmk4 10.0.0.10

    vmkping - I vmk5 10.0.0.10

    vmkping - I vmk6 10.0.0.10

    vmkping - I vmk7 10.0.0.10

    vmkping - I vmk8 10.0.0.10

    vmkping - I vmk9 10.0.0.10

    vmkping - I vmk1 10.0.0.11

    vmkping - I vmk2 10.0.0.11

    vmkping - I vmk3 10.0.0.11

    vmkping - I vmk4 10.0.0.11

    vmkping - I vmk5 10.0.0.11

    vmkping - I vmk6 10.0.0.11

    vmkping - I vmk7 10.0.0.11

    vmkping - I vmk8 10.0.0.11

    vmkping - I vmk9 10.0.0.11

    vmkping - I vmk1 10.0.0.12

    vmkping - I vmk2 10.0.0.12

    vmkping - I vmk3 10.0.0.12

    vmkping - I vmk4 10.0.0.12

    vmkping - I vmk5 10.0.0.12

    vmkping - I vmk6 10.0.0.12

    vmkping - I vmk7 10.0.0.12

    vmkping - I vmk8 10.0.0.12

    vmkping - I vmk9 10.0.0.12

    etc... etc...

    Do this on all hosts is to take more time than I'd like to take. Because we are busy of troubleshooting an issue on our switches where some of the ports VMK are unable to communicate to the target. Is there anyway that we can this script?

    Please guys, I'm desperate here.

    Kind regards

    Johan

    You can do it from a bash script.

    This is a working script that gets a list of all the vmkernel ports then each IP provided in a file list.txt on each vmkernel port pings. The results are printed to the screen but to get the results to just the output of the line pipe.

    Here is an example:

    "sh vmkping.sh > / tmp/vmkpingResults.log".

    #! / bin/bash

    # Name of the program: vmkpingall.sh

    # Store a file list.txt with each target IP storage on a separate line

    #---EXEMPLE list.txt-

    #172.16.191.50

    #172.16.192.50

    #-----------------------------

    #Print the date and host name

    Date

    host name

    #get a list of all the ports of vmk on the host

    for vmknum $ (esxcli network ip interface list | grep vmk | grep - v name :))

    do

    White space #Trim

    vmkCompare = "${vmknum # * ()}" "

    #Trim trailing whitespace

    vmkCompare = "${vmkCompare % * ()}" "

    # Exclude vmk0, because we do not use our management traffic vmotion vmkernel port so pings are supposed to do not on vmk0

    If ["$vmkCompare"! = "vmk0"]; then

    Cat /path-to-script/list.txt |  while reading output

    do

    #use vmkping port command selected vmk '-I ' ping target IP addresses

    vmkping - I "$vmknum" - ch. 1 "$output" >/dev/null

    If [$?-eq 0]; then

    echo 'node $output's place on $vmknum

    on the other

    echo "$output node is down on $vmknum.

    FI

    fact

    FI

    fact

  • Set the color of a .txt file?

    Hello

    I have a .txt file on my desktop that contains only 1 line of text: #79a3d2

    I also have the following code in a .jsx file.

    var fileToParse = File ('/Desktop/Photoshop.txt');
    fileToParse.open('r');
    var NewColor = fileToParse.readln();
    fileToParse.close();
    
    var color = app.foregroundColor;
    color.RGBColor.hexValue=NewColor;
    app.foregroundColor = color;
    

    I'm trying to change the color of foreground to the hex code in the text file, but I have an error message saying "Undefined is not an object"?

    Is someone can you please tell me what is the problem with my code (in layman's terms)?

    Thank you in advance.

    var File = fileToParse (Folder.desktop + ' / Photoshop.txt');

    fileToParse.open ('r');

    var NewColor = fileToParse.readln ();

    fileToParse.close ();

    app.foregroundColor.rgb.hexValue = NewColor;

  • Can I use javascript (in a button) to run 'save the attachment' for an attached file?

    (Acrobat DC, Windows 7 system)

    I have a PDF form that includes several attachments. Some of these attachments * may * must be recorded in the local file system of the user.

    What I would do, is add a button that includes javascript that will run the option 'Save the attachment' directly, rather than requiring the user to open the attachments Panel, select the file and select Save attachment.

    Thus, the user process would be:

    1. Click FooButton.
      Extract the file opens the window for the file FooAttachment.blah.
    2. The user accesses the desired backup folder and saves the file.

    Is it possible to do this with acrobat javascript? (I'd be happy with a specific example or a pointer to an explanation of how to access the different features similar :-)

    Pointers would be greatly appreciated.

    Yes, you are using the correct method to save the attached file, so the question is how you join it in the first place?

  • Save the page to enter a file

    Hello


    I have a task where a user should be able to save the nput on a page in a file.
    The page contains a form and a tabular presentation.
    The user must also have the ability to download the recorded files and save the corresponding data in the database.
    This is necessary for the possible inadequacies in internet connection and it is used in laptops.
    I wonder what would be the easiest way to do it.
    I thought that maybe it could be done so that the entire page is copied into the HTML and stored in a file. Then on download the corresponding input values of the objects are copied to the page and the page is then submitted. But how to copy the values of a BLOB?
    And I guess that there is a better way to do it?

    Any advice or comments would be really useful, because I have to get this loan soon.


    Tiina

    Hmmm... If your users want to start to edit the report in the apex itself, but to continue the same change even after the network connection is lost?
    I thought asking them to download excel first, edit (excel), and then upload it later.
    If this is the case, regardless of what you do at the top entered values will remain in the user's browser. Of course, you can use a tabular form based on a collection and use ajax automatic backup of data from time to time, but even that won't be very effective.

    Save the HTML code would probably be the only way (if they do not want to download excel). As I mentioned earlier, download this HTML file on an XML column and extract values from there. You can also combine approaches, by having a Javascript on the page dumps all the data in a text box in a separate comma structure which users can save a csv file, open in excel change I have and then transfer it too.

    Whatever the method used, you have a slight problem (that you've neglected). Once the connection is lost, request of the form in a table Pagination no longer work, users can run only on a single page (the one that is responsible), is the same with downloading the report to Excel again who needs a request to the server (so the javascript method that I mentioned would have this problem again). Save the report together in an HTML page (by using a value large paging) or modifying an excel would probably be the only way then.

  • marking of the words in a .txt file

    Hi all

    We have looked everywhere on the internet for a script we can use/buy. But can not find it anywhere.

    We have a fairly large document and an external list of words in a .txt file. This list contains the words that should be in the index at the end of the document.

    Instead of a few hundred words filling and by linking them to the hand, it would be great if there is a script that can handle this.

    We watched in Indexmatic2 (http://www.indiscripts.com/post/2011/07/indexmatic-2-public-release-and-user-s-guide ), but this script generates its own list of index and creates no links to the original words in the document.

    We found a script that can create indexes links between words colored in the document.

    Then someone knows if there is a script floating around that can load an external .txt wordlist and either color or add a character style to words in a document?

    Or even a script that does what you need in 1 GB?

    Thank you

    Thedesmodus,

    There is a script by Martin Fischer at www.hilfdirselbst.ch (swizz-German site) that might meet your needs. You can download it if you choose to be a premium member, which requires a small fee. It is written for InDesign CS3 but it should work with CS4 or CS5. I tested it with a small list of words, and it worked very well with InDesign CS5.

    http://InDesign.Hilfdirselbst.ch/text/indexeintrage-MIT-unterstichworten-uber-eine-konkord anzdatei - erzeugen.html

    If you prefer a Google translation:

    http://translate.Google.de/translate?HL=de&SL=de&TL=en&u=http%3A%2f%2Findesign.hilfdirselb st.ch%2Ftext%2Findexeintrage-mit-unterstichworten-uber-eine-konkordanzdatei-erzeugen.html

    Uwe

Maybe you are looking for