try:
sql_sw="select c1 from bd_t_sfsjpp_sw_temp t order by to_number(t.num)
db=cx_Oracle.connect('***/***@192.168.2.101:***/orcl')
print "连接数据库成功"
cursorSeq=db.cursor()
cursorSeq.execute(sql_sw)
rows = cursorSeq.fetchall()
except Exception,e:
print e
当执行以上代码时可能就会报错 ORA-29275部分多字节字符 这是因为数据库的编码格式的问题解决方法是将数据库里面的中文字符转换一下,使用以下的sql update bd_t_sfsjpp_sw_temp set c1 = TO_SINGLE_BYTE(c1) where lengthb(c1) <> lengthb(TO_SINGLE_BYTE(c1))
这样就会将半角与全角长度不相同的行更新。。
通过sql查询半角全角长度不一致的行:
select c1,lengthb(c1), lengthb(TO_SINGLE_BYTE(c1)) from bd_t_sfsjpp_sw_temp where lengthb(c1) <> lengthb(TO_SINGLE_BYTE(c1))