UTL_FILE.LINE problem with special characters (accents)

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Post Reply
HenriqueMachado
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 48
Joined: Mon, 29 May 2006 1:24 pm
Location: Blumenau - SC
Abraços,
Henrique Machado Muller

Personal I am with a specified character problems of the UTL_File

For example, let's go to the code

Select all

 
DECLARE  
    arquivo_ler UTL_FILE.File_Type;  
    AReg_Linha VARCHAR2(4000);  
BEGIN  
    DBMS_OUTPUT.ENABLE(100000);  
    DBMS_OUTPUT.PUT_LINE('ok');  
    arquivo_ler := UTL_FILE.FOPEN_NCHAR('DIR', '001662.TXT', 'r');     
    UTL_FILE.GET_LINE(arquivo_ler, AReg_Linha);  
END;  
obtains the result
code:

Select all

 
0;253610672;200706;ASSOCIA�O DOS FISSURADOS DO VALE DO ITAJA�1;2;3;1;1;1;2;2;3;2;1;5  
plus the original file of the file is
code:

Select all

0;253610672;200706;ASSOCIAÇÃO DOS FISSURADOS DO VALE DO ITAJAÍ;1;2;3;1;1;1;2;2;3;2;1;5  

Can anyone help me? I do not know what to do
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Brother,

Try to take a test, with the commands below?

Select all

 
SELECT ASCII('ç')  
  FROM dual; 
   
SELECT CHR(231)  
  FROM dual; 
Whatever, send it there.
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

I think the problem is as follows:
You opened the file in Unicode format (UTL_File.fopen_nchar)
and used the normal get_line!

Try to use:

Select all

UTL_FILE.GET_LINE_NCHAR
: -O
HenriqueMachado
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 48
Joined: Mon, 29 May 2006 1:24 pm
Location: Blumenau - SC
Abraços,
Henrique Machado Muller

Thanks for the response.
But I have not obtained success yet.

I tried seedlings the commands removing the nchar and putting ncling at all, the result was the same as the first Message.
Brother,

Try to take a test, with the commands below?
Code:

Select all

SELECT ASCII('ç')  
  FROM dual;  
   
SELECT CHR(231)  
  FROM dual; 
The result was this.

Select all

 
ASCII('�')                     
----------     
50087                                                                                                                                 
1 rows selected 
 
CHR(231)                              
--------                      
 
1 rows selected 
HenriqueMachado
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 48
Joined: Mon, 29 May 2006 1:24 pm
Location: Blumenau - SC
Abraços,
Henrique Machado Muller

I still can not find the solution.

Someone knows what it is?
khalilpereira
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 1
Joined: Mon, 13 Apr 2015 3:24 pm

Although it is an old topic worth responding because Google has as the first occurrence of the keywords this topic.

I was able to find the solution that It worked for my case.

Considering that the variable receiving the file line is

Select all

AReg_Linha
to convert the line of the file that must be utf8 [ / b] for the database format that should be We8mswin1252 .

Select all

AReg_Linha:=utl_raw.cast_to_varchar2(utl_raw.CONVERT(utl_raw.cast_to_raw(AReg_Linha),'BRAZILIAN PORTUGUESE_BRAZIL.WE8MSWIN1252', 'BRAZILIAN PORTUGUESE_BRAZIL.UTF8'));
User avatar
jime.santos
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Thu, 27 Jul 2017 10:47 am
Location: São Paulo, Barueri, São Paulo
Contact:

It is a tip to resolve accentuation in PLSQL

PL / SQL Developer Version 12.0.7.1837


Problem: PL / SQL Developer Exchanges Any Character Accentuated by the symbol "? ".

Solution: In Windows, create an environment variable called NLS_LANG, with the value .WE8ISO8859P1. As shown below.

Embrace


: -O
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest