cx_Oracle: Using PL/SQL RECORD types as arguments to stored procedures

大兔子大兔子 提交于 2019-12-23 23:19:41

问题


I'm attempting to call AP_VENDOR_PUB_PKG.CREATE_VENDOR from cx_Oracle (This is an Oracle R12 stored procedure) It requires an argument that is a predefined PL/SQL RECORD type. (AP_VENDOR_PUB_PKG.R_VENDOR_REC_TYPE)

Here's my python code:

connection = cx_Oracle.connect(...)
cursor = connection.cursor()
obj = cursor.var(cx_Oracle.Object,                              
                              typename='AP_VENDOR_PUB_PKG.R_VENDOR_REC_TYPE')
result = cursor.callproc('AP_VENDOR_PUB_PKG.CREATE_VENDOR',
                         parameters=["1.0", "T", "T", 
                                     "fnd_api.g_valid_level_full", obj])

This results in the following exception:

cx_Oracle.InterfaceError: object type not associated with bind variable

What am I doing wrong? How do I call a stored procedure that requries a record type?


回答1:


I have been able to get past this problem by using

type_obj = connection.gettype('AP_VENDOR_PUB_PKG_R_VENDOR_RE')
obj = type_obj.newobject()

Note that the name is limited to 29 characters, and the period (.) has been replaced with underscore (_)



来源:https://stackoverflow.com/questions/45360966/cx-oracle-using-pl-sql-record-types-as-arguments-to-stored-procedures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!