Search code examples
oracle-databaseplsqlexport-to-csvspecial-characters

characters issue when exporting as a csv file in oracle


I have a pl/sql block that exporting some data as a csv file. unfortunately, when I open this file with excel I am having characters issue. When I open the file in notepad, it seems okay but not working in excel. any idea? thanks.

data in the table

1

data in the excel

2

data in notepad

3

try to set NLS_LANGUAGE but not working


Solution

  • I fixed the issue. Open your file in binary mode, using

    t_fh := utl_file.fopen( p_dir, p_filename, 'wb' );
    

    And use this to write to it

    utl_file.put_raw( t_fh, utl_i18n.string_to_raw( 'èéê', 'WE8MSWIN1252' ) );
    
    UTL_FILE.PUT_RAW(v_file_handle, v_newline);
    
    v_newline     RAW(2)     := hextoraw('0A');
    

    So I don’t have any special characters issue anymore