Oracle:查询用户定义类型的值

我有一个用户定义的类型:
create or replace type my_message_type 
  as object (relatedid varchar2(50), payload clob);
我以编程方式插入了一条消息。 SQL Developer将插入的对象呈现为:
SYNESSO.MY_MESSAGE_TYPE('abcdefgh','oracle.sql.CLOB@1dae16a')
如何使用SQL查询此数据?例如,以下内容似乎很直观:
select count(1) from table_of_my_messages where user_data.relatedid = 'abcdefgh';
但这导致
ORA-00904: "USER_DATA"."RELATEDID": invalid identifier
。 然后我发现正确的语法是构造消息类型并使用相等性检查。但是如何构造一个类型的实例,其中一些字段与
any
匹配?:
select * from table_of_my_messages where user_data = my_message_type('abcdefgh', *);
-- ORA-00936: missing expression

select * from table_of_my_messages where user_data = my_message_type('abcdefgh');
-- ORA-02315: incorrect number of arguments for default constructor

select * from table_of_my_messages where user_data = my_message_type('abcdefgh', ?);
-- Missing IN or OUT parameter at index:: 1
    
已邀请:
直观的版本几乎是正确的。我只需要对表进行别名以使其工作......
select count(1) from table_of_my_messages m 
    where m.user_data.relatedid = 'abcdefgh';
    

要回复问题请先登录注册