Unicode characters in file name
908973Jan 5 2012 — edited Jan 7 2012Hi,
I try to open a file (using UTL_FILE functionalities) whose name contains polish characters (e.g. 'test-ś.txt').
In return, I get error message:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 633
ORA-29283: invalid file operation
Error is not due to missing rights on file/directory because when I replace the polish character by a latin one, file is opened successfuly.
I also tried to rename a file (using UTL_FILE.FRENAME) from latin to polish characters (e.g 'test-s.txt' -> 'test-ś.txt').
File is renamed but polish characters are lost (final result is something like 'test-Å›.txt').
What's wrong with my environment or code?
Thanks in advance for your help,
Arnaud
Here's my environment description, PL/SQL code and results.
Environment:
OS Windows in Polish for client box
* code page ACP=1250
* NLS_LANG=POLISH_POLAND.EE8MSWIN1250
OS Windows in US/English for database server
* code page ACP=1252
* NLS_LANG=AMERICAN_AMERICA.AL32UTF8
Oracle 10.2.0.5
* NLS_CHARACTERSET=AL32UTF8
* NLS_NCHAR_CHARACTERSET=AL16UTF16
Tests are executed from SQL Developer on client box.
The file I'm trying to open is located on database server.
So, Oracle Directory path used in FOPEN procedure is something like '\\server\directory'.
PL/SQL code:
-----------------------------------------------------------
SET SERVEROUTPUT ON;
declare
Message varchar2(1000);
Filename varchar2(1000); -- nvarchar2(1000);
FileHandler UTL_FILE.FILE_TYPE;
OraDir varchar2(30) := 'SGINSURANCE_DIR_SOURCE';
begin
dbms_output.enable(10000);
--Filename := 'test-s.txt';
Filename := 'test-ś.txt';
Message := 'Opening file ['||Filename||']';
dbms_output.put_line(Message);
--FileHandler := UTL_FILE.FOPEN_NCHAR(OraDir, Filename, 'r');
FileHandler := UTL_FILE.FOPEN(OraDir, Filename, 'r');
Message := 'Closing file';
dbms_output.put_line(Message);
UTL_FILE.FCLOSE(FileHandler);
exception
when others then
Message := 'Error: '||SQLERRM;
dbms_output.put_line(Message);
if UTL_FILE.IS_OPEN(FileHandler) then
Message := 'Closing file ['||Filename||']';
dbms_output.put_line(Message);
UTL_FILE.FCLOSE(FileHandler);
end if;
end;
-----------------------------------------------------------
Results:
Test with polish characters -> error ORA-29283: invalid file operation
-----------------------------------------------------------
anonymous block completed
Opening file [test-ś.txt]
Error: ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
-----------------------------------------------------------
Test without polish characters -> no error
-----------------------------------------------------------
anonymous block completed
Opening file [test-s.txt]
Closing file
-----------------------------------------------------------