我一整天都在努力尝试使用 cx_Oracle 从 PL/SQL 函数获取布尔值。我看过一些帖子讨论使用其他一些数据类型(如 char 或整数)来存储返回值,但是当我尝试使用此类解决方案时,我收到错误的数据类型错误。首先,让我展示代码。
def lives_on_campus(self):
cursor = conn.cursor()
ret = cursor.callfunc('students_api.lives_on_campus', bool, [self.pidm])
return ret
如果我使用 11.2.0.4 数据库客户端,则会出现以下错误。
File "student-extracts.py", line 134, in <module>
if student.lives_on_campus():
File "student-extracts.py", line 58, in lives_on_campus
ret = cursor.callfunc('students_api.lives_on_campus', bool, [self.pidm])
cx_Oracle.DatabaseError: DPI-1050: Oracle Client library is at version 11.2 but version 12.1 or higher is needed
如果我使用 12.1.0.2 数据库客户端或更高版本,则会收到此错误。
Traceback (most recent call last):
File "student-extracts.py", line 134, in <module>
if student.lives_on_campus():
File "student-extracts.py", line 58, in lives_on_campus
ret = cursor.callfunc('students_api.lives_on_campus', bool, [self.pidm])
cx_Oracle.DatabaseError: ORA-03115: unsupported network datatype or representation
基本上,无论我使用哪个版本的 SQL 客户端,它都会出错。现在,我知道如果数据库版本是 12c R2,上面的代码将会工作。不幸的是,我们的测试环境中只有该版本,并且 PROD 仅使用 11g 数据库。有什么可以使该功能与 11g 数据库一起使用吗?必须有一个解决方法。
海绵宝宝撒
相关分类