Thread: [cx-oracle-users] varchar2 length > 250
Brought to you by:
atuining
From: Kathryn M. <ka...@cs...> - 2006-06-21 16:37:52
|
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:hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh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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 |
From: Anthony T. <ant...@gm...> - 2006-06-22 16:40:21
|
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:hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh?^@uiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii > char:iiiii^@^@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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 > |
From: Kathryn M. <ka...@cs...> - 2006-06-24 22:59:50
|
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:hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh?^@uiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii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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 |
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:hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh?^@uiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii > >> char:iiiii^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ > ^@ > > ^ > >> @^@^@^@^@^@ > >> > >> 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 > |
From: Kathryn M M. <ka...@cs...> - 2006-06-26 21:29:16
|
Thanks, Anthony. I tried what you suggested, and it definitely changed=20 things, but it still doesn't work. The change is that the "weird"=20 characters in the middle of the output for the third print statement=20 (the 'h' record) are different. With NLS_LANG set on the client side to AMERICAN_AMERICA.US7ASCII, the=20 "weird" characters are "?^@u". The numeric values for these characters=20 are: 63, 0, 117, or hex 0x3f, 0x0, 0x75. With NLS_LANG set on the client side to AMERICAN_AMERICA.WE8ISO8859P1,=20 the weird characters are "=FE^@=FB". The numeric values for these charact= ers=20 are: 254, 0, 251, or hex 0xfe, 0x0, 0xfb. Given that the "weird" characters fall exactly where the record boundary=20 should be (position 252, because there should be only 251 h's in the=20 record), it seems like the record boundary character isn't being=20 interpreted correctly. I tried a bunch of different 8- and 7-bit encodings for NLS_LANG and=20 can't get it right. I'll keep experimenting, but am sending this in case=20 someone can shed some light. Thanks, Kathryn Anthony Tuininga wrote: > 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. :-) >=20 > 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. >=20 > On 6/24/06, Kathryn Mohror <ka...@cs...> wrote: >> I don't have much experience with character sets, but here's what I wa= s >> 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%2= 0faq.htm), >> I think that because NLS_LANG is not set, the default character encodi= ng >> 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. Perhap= s >>> 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 =3D "select b,c from temp_k" >>>> ptds.cursor.execute(sql) >>>> rets =3D ptds.cursor.fetchall() >>>> print ptds.cursor.description >>>> for b,c in rets: >>>> towrite =3D "byte:%s\n"% b >>>> f.write(towrite) >>>> towrite =3D "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 string= s as >>>> in step #2. Now I get garbage for the last two rows: >>>> byte:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb= bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb= bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb >>>> char:ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc= ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc= cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc >>>> byte:hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh= hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh= hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh= hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh?^@uiiiiiiiiiiiiiiiiiiiiiiiiiii= iiiiiiiiiiiiiiiiiiiiiiiiii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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 th= e 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, secur= ity? >>> Get stuff done quickly with pre-integrated technology to make your jo= b easier >>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Ger= onimo >>> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&d= at=3D121642 >>> _______________________________________________ >>> 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, securi= ty? >> 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 Gero= nimo >> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&da= t=3D121642 >> _______________________________________________ >> cx-oracle-users mailing list >> cx-...@li... >> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >> >=20 > Using Tomcat but need to do more? Need to support web services, securit= y? > 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 Geron= imo > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |