我正在尝试通过cx\U Oracle从用户定义类型(UDT)提取数据。以下是UDT结构:
CREATE OR REPLACE TYPE graphic_component AS OBJECT (
type NUMBER(6),
source_type NUMBER(4),
meta_type_id VARCHAR2(50 CHAR),
name VARCHAR2(100 CHAR),
extension_info VARCHAR2(500 CHAR),
symbology_tokens VARCHAR2(2000 CHAR)
);
CREATE OR REPLACE TYPE graphic_component_array AS
VARRAY (10000) OF graphic_component;
下面是一个使用Python的示例:
>>>insert = cursor.execute("SELECT COMPLEX FROM GRAPHIC WHERE ID=48662511087446403855368")
>>>complex = insert.fetchall()
[(<cx_Oracle.Object SCHEMA.GRAPHIC_COMPONENT_ARRAY at 0x33d71d0>,)]
>>>dir(complex)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'aslist', 'copy', 'delete', 'exists', 'extend', 'first', 'getelement', 'last', 'next', 'prev', 'setelement', 'size', 'trim', 'type']
>>>complex.first()
0
您可以看到有一个很好的用户定义类型,但我无法从这个UDT或任何其他UDT中提取数据。我尝试检查对象的所有属性,找到了方法first()、getelement()和last()。但这些函数只返回0。
是否有任何方法可以通过cx\U Oracle从UDT提取数据,或者是否有其他方法可以获取数据。
更新
<cx_Oracle.Object GRAPHIC_COMPONENT_ARRAY at 0x26c9f10>
Traceback (most recent call last):
File "C:/Users/petr.silhak/PycharmProjects/migration-to-postgresql/test_parsing.py", line 34, in <module>
print(ObjectRepr(complex[0][0]))
File "C:/Users/petr.silhak/PycharmProjects/migration-to-postgresql/test_parsing.py", line 9, in ObjectRepr
value = ObjectRepr(value)
File "C:/Users/petr.silhak/PycharmProjects/migration-to-postgresql/test_parsing.py", line 14, in ObjectRepr
value = getattr(obj, attr.name)
cx_Oracle.DatabaseError: DPI-1014: conversion between Oracle type 2010 and native type 3000 is not implemented