Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting SQLPlus to spool out Unicode characters, are being output as?

I am attempting to get Oracle sqlplus (10.2) to spool out Unicode data on a Linux machine. I have found several discussions of this issue, but no clear answers, other than to check locale settings and set NLS_LANG to AL32UTF8. All locale info is set to "en_US.UTF-8", I'll post the full output upon request.

The OS (vi, etc.), will recognize and accept Unicode characters without issue. However, when using sqlplus, all non-ASCII characters are changed to ? characters. The Oracle DB has NLS_CHARACTERSET set to AL32UTF8, and NLS_NCHAR_CHARACTERSET set to AL16UTF16.

Am I missing some setting or switch that needs to be set for sqlplus itself? Any ideas would be much appreciated.

like image 265
Todd Allen Avatar asked Aug 24 '11 16:08

Todd Allen


People also ask

How do I spool in SQL Plus?

In iSQL*Plus, use the preference settings to direct output to a file. Represents the name of the file to which you wish to spool. SPOOL followed by file_name begins spooling displayed output to the named file. If you do not specify an extension, SPOOL uses a default extension (LST or LIS on most systems).

How do you spool output in Oracle PL SQL?

In order to execute a spool file in plsql Go to File->New->command window -> paste your code-> execute. Got to the directory and u will find the file.

What is Character Set AL32UTF8?

AL32UTF8. The AL32UTF8 character set supports the latest version of the Unicode standard. It encodes characters in one, two, or three bytes. Supplementary characters require four bytes. It is for ASCII-based platforms.


1 Answers

I found the answer to this. Apparently, setting NLS_LANG (the correct setting is AMERICAS_AMERICA.AL32UTF8) in the shell script does not work. It must be exported:

export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
like image 164
Todd Allen Avatar answered Oct 06 '22 03:10

Todd Allen