我有一个具有许多属性的用户定义类型,如下所示:
create or replace type MyObject is object
(
attribute 1,
attribute 2,
attribute 3
...
)
我有一个返回该对象的函数:
create or replace function GetMyObject
(...params...)
return MyObject
is
...
现在,我尝试使用Oracle.ManagedDataAccess.Client
从C#应用程序中调用该函数。由于C#未知MyObject
的类型,因此我尝试调用OracleCommand.ExecuteReader()
并从结果查询中逐个读取属性值:
select GetMyObject(...) from dual;
我在Oracle中得到的是这张表:
| GetMyObject(...) |
--------------------------------
1 | [UserName.MyObject] |
相反,我希望得到这个:
| attribute 1 | attribute 2 | attribute 3 | ...
------------------------------------------------------
1 | value 1 | value 2 | value 3 | ...
select语句应如何显示?
答案 0 :(得分:1)
“对象”的全部要点是它们是复合数据,被视为单个单位。这就是为什么您看到自己看到的东西。
如果要查看各个组件,则需要SELECT
三列(或多列),而不是一列。要访问各个属性(每列一个属性),您必须使用“点”表示法。
select GetMyObject(...).attribute1 as attribute1
, GetMyObject(...).attribute2 as attribute2
-- (etc.)
from dual;
很明显,我认为您实际上在属性名称中没有空格。