Re: selecting nvarchar with Oratcl?
- From: "thelfter@xxxxxxxxx" <thelfter@xxxxxxxxx>
- Date: Wed, 28 Nov 2007 05:23:49 -0800 (PST)
On Nov 28, 7:41 am, schl...@xxxxxxxxxxxxxxxx wrote:
Hi all,
maybe someone can enlighten me how to correctly use Oratcl to select
nvarchar from a database.
I try to verify some setup where a python based oracle connector
(cx_Oracle) fails badly and want to check if its my environment or a
problem with OCI libs or something else, so i used Oratcl for a
verification.
Basically i try to select an char created with NCHR() in oracle
(National Character Set).
I currently have no idea whats still wrong with it.
Michael
The database encoding setup is like this:
OCI from instantclient10_1 (oci.dll Version 10.01.0000.0004)
NLS_LANG set to GERMAN_GERMANY.AL32UTF8 before loading Oratcl
Windows XP SP 2
from sqlplus:
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 WE8MSWIN1252
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.3.0
# with utfmode 1
C:\unicode>tclsh testuc.tcl
Could match without conversion 127
Could match with utf-8 conversion 206
# with utfmode 0
C:\unicode>tclsh testuc.tcl
Could match without conversion 238
Could match with utf-8 conversion 180
# Tcl and Oratcl are from the ActiveTcl build
C:\unicode>tclsh
% info patchlevel
8.4.16
% package require Oratcl
4.4
%
My Oratcl test script looks like this:
set ::env(PATH) {c:\sdk\win32\1.0\instantclient10_1}
set ::env(TNS_ADMIN) U:\\
set ::env(NLS_LANG) GERMAN_GERMANY.AL32UTF8
package require Oratcl
proc loop_utf8 {handle} {
set shandle [oraopen $handle]
oraconfig $shandle utfmode 0 ;# changing this just changes the
amount of non-matches a little bit, but not much
oraparse $shandle {SELECT
ASCIISTR(nchr(:codepoint)),nchr(:codepoint) FROM DUAL}
set hits 0
set utfhits 0
for {set i 1} {$i < 3000} {incr i} {
set code [format {\u%04x} $i]
eval set c $code
orabind $shandle :codepoint $i
if {[catch {
oraexec $shandle
} msg]} {
puts $::errorInfo
puts "Failed at Index $i"
}
while {1403 != [orafetch $shandle -datavariable r]} {
set ascii [lindex $r 0]
set val [lindex $r 1]
set val2 [encoding convertfrom utf-8 $val]
if {$val == $c} { incr hits}
if {$val2 == $c} { incr utfhits}
}
}
puts "Could match without conversion $hits"
puts "Could match with utf-8 conversion $utfhits"
}
set handle [oralogon "scott/tiger@DEV1"]
loop_utf8 $handle
oralogoff $handle
exit 0
Hello,
I'm afraid I'm not going to be much help to you, even though I'm
supposed to be able too.
The 'utfmode' flag tells the 'C' library to perform code similar to
the bottom.
1221 if (StmPtr->utfmode) {
1222 Tcl_ExternalToUtfDString(NULL,
1223 tmp,
1224 -1,
1225 &uniStr);
1226 tmp = Tcl_DStringValue(&uniStr);
1227 }
Which converts the values into the native system encoding?
Tcl_Encoding encoding (in)
The encoding to query, free, or use for converting text. If encoding
is NULL, the current system encoding is used.
There are others on this board, who have gotten NVARCHAR2 to work.
Hopefully they can reply.
-Todd
.
- Follow-Ups:
- Re: selecting nvarchar with Oratcl?
- From: schlenk
- Re: selecting nvarchar with Oratcl?
- References:
- selecting nvarchar with Oratcl?
- From: schlenk
- selecting nvarchar with Oratcl?
- Prev by Date: Dangerous update command
- Next by Date: Re: tablelist: embed abutton in cells
- Previous by thread: selecting nvarchar with Oratcl?
- Next by thread: Re: selecting nvarchar with Oratcl?
- Index(es):