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
  

Poston Wed, 14 Nov 2007 9:26 am

Guys IM with a special string of problems For the exempleficar UTL_FILE code
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;
Gets the result code:
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
Over the original line of the file is code:
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
could someone help me? I don't know what to do
HenriqueMachado
Location: Blumenau - SC

Abraços,
Henrique Machado Muller

Poston Wed, 14 Nov 2007 9:48 am

Brother, try to do a test with the commands below.
Code: Select all
SELECT ASCII('ç')
  FROM dual;
 
SELECT CHR(231)
  FROM dual;
qualquer thing, says ai.
Trevisolli
Location: Araraquara - SP

Abraço,

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

Poston Wed, 14 Nov 2007 9:53 am

I think the problem is the following: you have opened the file in UNICODE format (UTL_FILE.FOPEN_NCHAR) and used the normal GET_LINE!

Try using: UTL_FILE.GET_LINE_NCHAR :-
dr_gori
Location: Seattle, WA, USA

Thomas F. G
https://www.patreon.com/glufke

Poston Wed, 14 Nov 2007 10:41 am

Thanks for the reply.
But still not getting success.

I tried to change the commands by removing the NCHAR NCHAR and placing at all, the result was the same as the first message.

Brother, try to do a test with the commands below.
Code: SELECT ASCII (' ä ') FROM dual;

SELECT CHR (231) FROM dual;



The result was this.

Code: Select all
ASCII('�')                   
----------   
50087                                                                                                                               
1 rows selected

CHR(231)                             
--------                     

1 rows selected
HenriqueMachado
Location: Blumenau - SC

Abraços,
Henrique Machado Muller

Poston Thu, 13 Dec 2007 2:04 pm

I haven't been able to find the solution.

Anyone know what it is?
HenriqueMachado
Location: Blumenau - SC

Abraços,
Henrique Machado Muller

Poston Mon, 27 Apr 2015 6:42 pm

Despite being an old topic worth answer lot because Google has as first occurrence of keywords this problem this topic.

I couldn't find the solution that worked for my case.

Whereas the variable that receives the file line is
Code: Select all
AReg_Linha
to convert the line to the file that must be UTF8 for the format of the database that must be WE8MSWIN1252.

Code: 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'));
khalilpereira

Poston Wed, 24 Jan 2018 4:01 pm

A tip to solve accentuation in PLSQL PL/SQL Developer Version https://srcoelho.com.br/2012/08/14/acen ... er/Problem 12.0.7.1837: PL/SQL Developer Exchange any character marked by the symbol \"?\".

Solution: in windows, create an environment variable called NLS_LANG, with the value. We8iso8859p1. As shown in figure below.

Hug:-
jime.santos
Location: São Paulo, Barueri, São Paulo


  • See also
    Replies
    Views
    Last Post