469,602 Members | 1,826 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

python 2.3.4, cx_Oracle 4.1 and utf-8 - trouble

Hello!

Trying to fetch long varchar2 column and get the following error:

cx_Oracle.DatabaseError: column at array pos 0 fetched with error: 1406

i.e. string buffer is not much enough to fetch the string.

# fragment of code...
myCon = cx_Oracle.connect(user, psw, dsn)
myCur = myCon.cursor()
myCur.execute("""
select COLUMN from TABLE where ID=1
""")
for record in myCur.fetchall():
# ...

Error is reproduced only if actual string value longer than half of
declared column size. For short strings all is ok.

If I print myCur.description, I get:

[('COLUMN', <type 'cx_Oracle.STRING'>, 250, 250, 0, 0, 1)]

250 - declared column max size, but I guess cx_Oracle allocates only 250
bytes(!), so if my string longer than 125 chars (utf-8 national char
occupies > 1 byte) - I get the error.

Is it bug or what? Any suggestions?

Extra info:
OS - SuSE Linux 9.2
Client - Oracle Client 9.2.0.1.0
NLS_LANG="RUSSIAN_CIS.UTF8"

--
Best regards, Maxim Kuleshov
Jul 19 '05 #1
1 3983
Maxim Kuleshov wrote:
Hello!

Trying to fetch long varchar2 column and get the following error:

cx_Oracle.DatabaseError: column at array pos 0 fetched with error: 1406
i.e. string buffer is not much enough to fetch the string.

# fragment of code...
myCon = cx_Oracle.connect(user, psw, dsn)
myCur = myCon.cursor()
myCur.execute("""
select COLUMN from TABLE where ID=1
""")
for record in myCur.fetchall():
# ...

Error is reproduced only if actual string value longer than half of
declared column size. For short strings all is ok.

If I print myCur.description, I get:

[('COLUMN', <type 'cx_Oracle.STRING'>, 250, 250, 0, 0, 1)]

250 - declared column max size, but I guess cx_Oracle allocates only 250 bytes(!), so if my string longer than 125 chars (utf-8 national char
occupies > 1 byte) - I get the error.

Is it bug or what? Any suggestions?


Googling for "varchar2 utf-8" suggests that it's an Oracle's
feature (or issue). varchar2 is allocated in bytes. Finding
out the largest number of bytes per character is left as
an exercise :)

Sergey.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Bryan J Gudorf | last post: by
7 posts views Thread by vb_bv | last post: by
4 posts views Thread by hot.favorite | last post: by
reply views Thread by cirudinezidane | last post: by
8 posts views Thread by Richard Schulman | last post: by
reply views Thread by M.-A. Lemburg | last post: by
3 posts views Thread by Raja | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.