I am trying to query a table from a Oracle 9i db, using Python with jaydebeapi. It connects successfully, the cursor and fecth seems to work well, but when I display the results, only the numeric fields of the table are available.
I tried some Oracle functions like TO_CHAR, SUBSTR and TRIM to see if changing its value could help showing it, but none of them worked.
import jaydebeapi
import jpype
import os
sql = "select 0 as order, ST_CODE_PDV, ST_NAME_PDV, ST_CHANNEL, \
ST_ACCESS, 'Safra', sum(ACTIVATION), sum(FRAUD) \
from MY_TABLE \
WHERE ST_CODE_PDV <> '-1' \
HAVING sum(FRAUD) > 0 \
group by ST_CODE_PDV, ST_NAME_PDV, ST_CHANNEL, ST_ACCESS, 'Safra'"
try:
jar = os.getcwd()+'\ojdbc8.jar'
args = '-Djava.class.path=%s' % jar
jpype.startJVM("C:\\Program Files\\Java\\jre1.8.0_121\\bin\\server\\jvm.dll", args)
cn = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver','jdbc:oracle:thin:@dbserverinfo', ["user","pass"])
print("Connection Successful")
curs = cn.cursor()
curs.execute(sql)
result = curs.fetchall()
for r in result:
print(r)
curs.close()
cn.close()
except Exception as e:
print("connection error:", e)
The expected result is:
(0.0, 'NE99_TSR02X_TS9876_XY001', 'STARK TELECOM', 'AGENT SALES', '', 'Safra', 6.0, 1.0)
But my code displays:
(0.0, '', '', '', '', 'Safra', 6.0, 1.0)
The fields that do not display any results are VARCHAR2 type. The string 'Safra' is displayed, but it's hardcoded in my query.
I tried other tables, but the problem is the same (only numeric fields are returned).
What may be happening?