Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Issue while exporting special characters through UTL_FILE

Ashu OrclApr 7 2016 — edited Apr 8 2016

Hi Experts/Friends,

My DB version is Oracle Database 10g Release 10.2.0.4.0 - 64bit Production

I have procedure to export data from DB to txt file. But some fields have special character like « which after exporting gets converted into some weird/junk character like below

special_char.jpg

My problem is I cannot replace that with some other character or with NULL, whereas it should get exported same as «

In table it is stored as « also when I query the data it shows the same, but one I export through UTL_FILE as txt file it is shown as above image.

Below is anonymous block for your reference;

Let me know if anyone can guide me on same. Thanks in advance.

DECLARE

v_file UTL_FILE.file_type;

BEGIN

v_file := UTL_FILE.fopen ('RPT_DIR', 'testing.txt', 'W');

FOR i IN (SELECT ROWNUM rn, t_dat FROM te)

LOOP

  UTL\_FILE.put\_line (v\_file, i.rn || CHR (9) || I.t\_dat);

END LOOP;

UTL_FILE.fclose (v_file);

END;

Best Regards,

Ash

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2016
Added on Apr 7 2016
13 comments
1,836 views