Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Oracle / Oracle Server / November 2005

Tip: Looking for answers? Try searching our database.

Unicode and Oracle

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ebarrett@metastorm.com - 18 Nov 2005 17:09 GMT
I have been looking at what's involved in migrating our product to
unicode.   While most issues have been successfully resolved, I
recently ran into a problem which raised further questions.

There are a number of points in our stored procedures where direct SQL
is employed.   This is used where the table name is only known at
runtime.   So this involves usage of EXECUTE IMMEDIATE; also the OPEN
... FOR construct for returning a cursor to a recordset.

The difficulty arises when I attempt to run direct SQL which refers to
a table name which is unicode.   The reason it's a problem is that
EXECUTE IMMEDIATE does not accept a unicode SQL command (ie N'SELECT *
FROM ...').   Unfortunately, neither can I pass in the table name as a
parameter with the USING clause - Oracle doesn't allow this for table
names.   Meaning that in effect any table name I pass in has to be
coerced into an ANSI string.   I'd prefer not to mandate Roman script
to, say, a Chinese customer if I don't have to.

All of which raised another question:  does Oracle support unicode
table or column names?   I've done some searching on this and been
unable to arrive at a definite conclusion.

I'd be much obliged if someone could shed some light on this for me.
The Oracle versions of interest are 9.2 and later.

Thanks in advance,

Ed Barrett
Metastorm Inc.
Sybrand Bakker - 18 Nov 2005 17:38 GMT
>I have been looking at what's involved in migrating our product to
>unicode.   While most issues have been successfully resolved, I
[quoted text clipped - 25 lines]
>Ed Barrett
>Metastorm Inc.

You are aware of the difference between the National characterset and
the characterset? The example you provide seems you want to use the
National characterset for DML, which is very strange as that isn't the
purpose of the National characterset.
In short, the characterset of the database determines which characters
are allowed in SQL. The national characterset (when indicated, and
when the affected column is a NVARCHAR2) indicates which characters
can be stored in the table.
You would never be able to prefix any dynamic statement with N', as
the national characterset isn't used in SQL statements.

--
Sybrand Bakker, Senior Oracle DBA
Laurenz Albe - 28 Nov 2005 08:18 GMT
> I have been looking at what's involved in migrating our product to
> unicode.   While most issues have been successfully resolved, I
[quoted text clipped - 20 lines]
> I'd be much obliged if someone could shed some light on this for me.
> The Oracle versions of interest are 9.2 and later.

According to point 6 in
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements00
8.htm#sthref817

it is perfectly ok to use Unicode characters for a table name as long as
you refer to it in double quotation marks.

The table names must be in the database character set and not in the
national character set, however.

So it should be:

EXECUTE IMMEDIATE 'SELECT * FROM "MYSCHEMA"."MYUNICODETABLENAME"'

and not

EXECUTE IMMEDIATE N'SELECT * FROM MYSCHEMA.MYUNICODETABLENAME'

Yours,
Laurenz Albe
Frank van Bortel - 29 Nov 2005 20:35 GMT
>>I have been looking at what's involved in migrating our product to
>>unicode.   While most issues have been successfully resolved, I
[quoted text clipped - 39 lines]
> Yours,
> Laurenz Albe

Which is a bad idea...
Once a table "MyUniCodeTablename" is created you rmust always refer to
it as "MyUniCodeTablename" - case and quotes included.
Signature

Regards,
Frank van Bortel

Top-posting is one way to shut me up...

Laurenz Albe - 30 Nov 2005 08:06 GMT
>> The table names must be in the database character set and not in the
>> national character set, however.
[quoted text clipped - 13 lines]
> Once a table "MyUniCodeTablename" is created you rmust always refer to
> it as "MyUniCodeTablename" - case and quotes included.

I never said it was a good idea to use anything but ASCII7 for table
names.

Yours,
Laurenz Albe
Frank van Bortel - 30 Nov 2005 11:37 GMT
>>Which is a bad idea...
>>Once a table "MyUniCodeTablename" is created you rmust always refer to
[quoted text clipped - 5 lines]
> Yours,
> Laurenz Albe

Laurenz,

it was more a reaction to the OP; the contents of your
writing is correct, and aswered the question. I was merely
venting a feeling about the whole idea.

Apart from that - "table name is only known at
runtime"....?

Sound like creating tables on the fly - very un-Oracle!
Signature

Regards,
Frank van Bortel

Top-posting is one way to shut me up...

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.