Skip to Main Content

Database Software

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Unicode support in Oracle 10g on HP-UX 11.11

538341Oct 9 2006 — edited Oct 17 2006
Hi,

We are facing problem in using unicode on HP-UX 11.11 with Oracle 10g combination.
Following sample proc pgm tries to insert a sample record in NVARCHAR2 column using uvarchar proc datatype.

But before reaching to SQL level ir crashes giving a segmentation fault at wcscpy line.
We observed that
sizeof(wchar_t) = 4 // c++ datatype
sizeof(utext) = 2 on HP-UX. Will it create any problem?
We tried setting NLS_LANG on server to AMERICAN_AMERICA.WE8ISO8859P1 and AMERICAN_AMERICA.UTF8.
and DB characteristics are as follows.

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Oct 4 18:09:48 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from nls_database_parameters;

PARAMETER VALUE
-------------------------------------------------------------------
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CHARACTERSET WE8ISO8859P1
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM

PARAMETER VALUE
------------------------------ -----------------------------------
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_RDBMS_VERSION 10.2.0.1.0

20 rows selected.


#include
#include
#include
#include
#include

#include "/opt/db/oracle/product/10g/xdk/include/oratypes.h"
#include "/opt/db/oracle/product/10g/precomp/public/sqlucs2.h"
#include "/opt/db/oracle/product/10g/precomp/public/sqlca.h"

EXEC SQL INCLUDE SQLCA;
int main()
{

EXEC SQL BEGIN DECLARE SECTION;
uvarchar pref_name_u[35] ;
uvarchar pref_name_g[35] ;
EXEC SQL END DECLARE SECTION;

printf("Before wcscpy \n");
wcscpy((wchar_t *)pref_name_u.arr,L"SAMPLE");---------> This line gives a segmentation fault.
printf("After wcscpy \n");
pref_name_u.len = 6;
pref_name_u.arr[6]= L'\0';

EXEC SQL DELETE mc_dummy;

EXEC SQL COMMIT ;

printf("WIDECHAR Data to be inserted is : %S\n", (wchar_t* )pref_name_u.arr );
EXEC SQL INSERT INTO mc_dummy VALUES ( ref_name_u );

printf("sql retcode for insertion is : %d \n", sqlca.sqlcode );
EXEC SQL COMMIT ;

EXEC SQL SELECT name INTO ref_name_g FROM mc_dummy;

printf("sql retcode for fetch is : %d \n", sqlca.sqlcode );
printf("fetched data length is :%d\n",pref_name_g.len);
pref_name_g.arr[pref_name_g.len]= L'\0';

printf("fetched data is : %S \n", (wchar_t *)pref_name_g.arr );

return 0;
}
Table details :
SQL> desc mc_dummy;
Name Null? Type
---------------------------- -------- ----------------------------
NAME NVARCHAR2(100)

However when we made the following changes to the proc program we were able to insert and fetch the data.
#define utext unsigned int
This results in making sizeof(utext) same as sizeof(wchar_t) = 4.

But the data inserted into DB consumed morethan 1 byte per character. So though the column size is specified as 100, we were not able to insert 100. ( not even 50 ).

This is our urgent project requirement.
Could any one guide us in case we are missing anything.
Are we missing any DB settings?
Thanks
--------
Makarand Kulkarni

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 14 2006
Added on Oct 9 2006
8 comments
4,650 views