selecting nvarchar with Oratcl?
- From: schlenk@xxxxxxxxxxxxxxxx
- Date: Wed, 28 Nov 2007 04:41:55 -0800 (PST)
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
.
- Follow-Ups:
- Re: selecting nvarchar with Oratcl?
- From: thelfter@xxxxxxxxx
- Re: selecting nvarchar with Oratcl?
- Prev by Date: Re: linux newbie starting tcl
- Next by Date: Dangerous update command
- Previous by thread: linux newbie starting tcl
- Next by thread: Re: selecting nvarchar with Oratcl?
- Index(es):
Relevant Pages
|