如何根据对象的查询返回对象
I have a table a based on the object a_obj:
CREATE TYPE a_obj IS OBJECT (
a1 INTEGER,
a2 integer
);
CREATE TABLE a OF a_obj (
CONSTRAINT a__a1__pk PRIMARY KEY (a1)
);
Sometime i want to select the column of a:
select a.* from a -- it works
sometime I want to select the object a_obj.
select a_obj(a.a1,a.a2) from a; --works
但是我不想重写所有列的名称,因为,我可以写很多列要写,而且很容易忘记一个列。
我尝试这样的事情:
select a_obj(a.*) from a;
ORA-01747:无效的用户。
it doesn't work.
有办法做到吗?
that doesn't work either:
declare
ret a_obj;
begin
select a.* into ret
from a;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用:
或,AS @padders评论 ,使用:
需要参考表别名而不是表标识符。
db<>>
Use the
OBJECT_VALUE
pseudo-column:Or, as @padders commented, use the
VALUE()
function:Which needs to reference a table alias and not the table identifier.
db<>fiddle here