Re: [cx-oracle-users] varchar2 length > 250
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2006-06-26 14:22:01
|
I don't have much experience with character sets either so if someone else with greater knowledge is on this list, feel free to jump in. :-) I don't believe you need to set the NLS_LANG variable on the server since that is covered by the NLS_DATABASE_PARAMETERS. Instead, set your NLS_LANG on the client to AMERICAN_AMERICA.WE8ISO8859P1 and try your queries again. On 6/24/06, Kathryn Mohror <ka...@cs...> wrote: > I don't have much experience with character sets, but here's what I was > able to find out. > > Server side: > -------------- > NLS_LANG is not set. > NLS_DATABASE_PARAMETERS: > NLS_LANGUAGE AMERICAN > NLS_TERRITORY AMERICA > NLS_CHARACTERSET WE8ISO8859P1 > From my reading > (http://www.oracle.com/technology/tech/globalization/htdocs/nls_lang%20faq.htm), > I think that because NLS_LANG is not set, the default character encoding > for database entries is AMERICAN_AMERICA.US7ASCII. > > Client side: > ------------- > NLS_LANG is not set. > >>> import sys, locale > >>> print locale.getdefaultlocale() > (None, None) > >>> print sys.stdout.encoding > ANSI_X3.4-1968 > I think that the oracle instant client uses the default values when > NLS_LANG is not set (AMERICAN_AMERICA.US7ASCII). I would think that > this default encoding is compatible with the system encoding because > they're both 7-bit ascii. > > However, even though I think the encodings are compatible, retrieving > the characters and printing them doesn't "just work." My suspicion is > that the problem occurs because NLS_LANG is not set on the server side. > I have not yet experimented with setting this though. > > Any advice would be greatly appreciated. > Thanks, > Kathryn > > Anthony Tuininga wrote: > > Hmm, I tried the steps you gave and did not get the same results. The > > possibility, however, is that the database character set and the > > client character set are not the same as the ones you've used. Perhaps > > you can detail that information as well? If it gets too much into the > > unicode side of things I won't be able to be much help but others > > might be able to help on that front..... > > > > On 6/21/06, Kathryn Mohror <ka...@cs...> wrote: > >> Hi, > >> > >> I am trying to select and print strings from an Oracle 10.1.0.3.0 > >> database using cx_Oracle 4.1.2 and python 2.4.2. > >> > >> The problem: If I insert strings into a VARCHAR2 field with > 250 > >> characters, I get garbage when I retrieve them. > >> > >> Example test scenario: > >> > >> 1. in sqlplus, I execute the following commands: > >> create table temp_k (b varchar2(500 byte), c varchar2(500 char)); > >> insert into temp_k (b,c) values (rpad('b',200,'b'),rpad('c',200,'c')); > >> commit; > >> > >> 2. Now I use cx_oracle to retrieve the strings: > >> sql = "select b,c from temp_k" > >> ptds.cursor.execute(sql) > >> rets = ptds.cursor.fetchall() > >> print ptds.cursor.description > >> for b,c in rets: > >> towrite = "byte:%s\n"% b > >> f.write(towrite) > >> towrite = "char:%s\n"% c > >> f.write(towrite) > >> > >> I get the output I expect. > >> [('B', <type 'cx_Oracle.STRING'>, 500, 500, 0, 0, 1), ('C', <type > >> 'cx_Oracle.STRING'>, 500, 500, 0, 0, 1)] > >> byte:bbbbbbbbbbbb <snip for space> up to 200 > >> char:cccccccccccc <snip for space> up to 200 > >> > >> 3. Now, in sqlplus, I execute: > >> insert into temp_k (b,c) values (rpad('h',251,'h'),rpad('i',251,'i')); > >> commit; > >> > >> 4. Now, from my python script using cx_oracle, I retrieve the strings as > >> in step #2. Now I get garbage for the last two rows: > >> byte:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb > >> char:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc > >> byte:hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh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^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ > ^@ > > ^ > >> @^@^@^@^@^@ > >> > >> If I insert more rows of length < 251 after step #4, those rows are also > >> returned as garbage. When I retrieve these strings via sqlplus or the QT > >> interface, I do not receive garbage. > >> > >> Do you know what is happening here? > >> > >> Thanks, > >> Kathryn > >> > >> > >> > >> _______________________________________________ > >> cx-oracle-users mailing list > >> cx-...@li... > >> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > >> > > > > Using Tomcat but need to do more? Need to support web services, security? > > Get stuff done quickly with pre-integrated technology to make your job easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > cx-oracle-users mailing list > > cx-...@li... > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |