oracle 长查询无返回,cx_Oracle查询返回零行

在IBM AIX上运行的Python 2.6程序中,使用cx_Oracle库执行SQL查询时遇到问题。代码尝试从Table_1表中选取满足多个条件的数据,但返回结果为零行。尽管简单的查询能正常工作,但在带有参数的复杂查询中出现了问题。检查点在于绑定变量是否正确,以及数据库连接和游标的使用是否恰当。
摘要由CSDN通过智能技术生成

为什么下面的代码不起作用?它返回零行,即使我有多个匹配的搜索条件。

表单select * from Table_1的简单查询可以正常工作并返回正数行import cx_Oracle

def function_A (data):

connection = cx_Oracle.connect('omitted details here')

for index in range(len(data)):

# connection is already open

cursor = connection.cursor()

query = "select * from Table_1 where column_1=:column1 and column_2=:column2 and column_3=:column3 and column_4=:column4"

bindVars={'column1':data[index][3], 'column2':data[index][4], 'column4':data[index][5], 'column5':data[index][6]}

cursor.execute(query, bindVars)

cursor.arraysize = 256

rowCount = 0

resultSet = cursor.fetchall()

if (resultSet != None):

logger.debug("Obtained a resultSet with length = %s", len(resultSet))

for index in range(len(resultSet)):

logger.debug("Fetched one row from cursor, incrementing counter !!")

rowCount = rowCount + 1

logger.debug("Fetched one row from cursor, incremented counter !!")

logger.debug("Successfully executed the select statement for table Table_1; that returned %s rows !!", rowCount)

logger.debug("Successfully executed the select statement for table Table_1; that returned %s rows !!", cursor.rowcount)

请忽略一些小的格式化问题,代码运行只是没有给我正数行。

代码使用python2.6和兼容版本的cx_Oracle在IBM AIX上运行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值