我正在尝试在嵌套表中插入引用,但我一直收到错误SQL错误:ORA-00936:缺少表达式
相关类型和表格如下:
create type TP1_PROPRIETE as object (
NO_PROPRIETE number(10),
ADRESSE_PRO varchar2(20),
VILLE_PRO varchar2(20),
NB_PIECES_PRO number(2));
/
create type TP1_CAPROPRO as object (
REF_PROPRIETE_CAPROPRO ref TP1_PROPRIETE);
/
create type TP1_CAPROPRO_NT as table of TP1_CAPROPRO;
/
create type TP1_PARTENAIRE as object (
NOM_COMPLET_PAR varchar2(40));
/
create type TP1_PARTENAIRE_NT as table of TP1_PARTENAIRE;
/
create type TP1_PROPRIETAIRE as object (
NO_PROPRIETAIRE number(10),
NOM_COMPLET_PROR varchar2(40),
REF_PARTENAIRES_PROR TP1_PARTENAIRE_NT,
REF_PROPRIETES_PROR TP1_CAPROPRO_NT);
/
create table TP1_PROPRIETAIRE_T of TP1_PROPRIETAIRE
nested table REF_PARTENAIRES_PROR store as TP1_PARTENAIRE_NT_PROR
nested table REF_PROPRIETES_PROR store as TP1_CAPROPRO_NT_PROR;
/
create table TP1_PROPRIETE_T of TP1_PROPRIETE (
constraint CT_NB_PIECES_NON_NEG check (NB_PIECES_PRO > 0));
/
以下是插页:
insert into TP1_PROPRIETE_T
values(1465798654,
'1170 Victory',
'New York',
5);
/
insert into TP1_PROPRIETAIRE_T
values(9654255475,
'Mike Ross',
TP1_PARTENAIRE_NT(TP1_PARTENAIRE('Andre Ross')),
TP1_CAPROPRO_NT(TP1_CAPROPRO(select ref(p)
from TP1_PROPRIETE_T p
where p.NO_PROPRIETE = 1465798654)));
/
执行最后一次插入时出现以下错误:
Error starting at line 117 in command: insert into TP1_PROPRIETAIRE_T values(9654255475, 'Mike Ross', TP1_PARTENAIRE_NT(TP1_PARTENAIRE('Andre Ross')), TP1_CAPROPRO_NT(TP1_CAPROPRO(select ref(p) from TP1_PROPRIETE_T p where p.NO_PROPRIETE = 1465798654))) Error at Command Line:121 Column:39 Error report: SQL Error: ORA-00936: missing expression 00936. 00000 - "missing expression" *Cause: *Action:
根据我从SO和其他论坛上读到的内容,错误最有可能出现在最后一个选择ref(p)...但语法对我来说似乎很好,所以我真的不知道为什么我得到这个错误。谢谢你的时间。
答案 0 :(得分:1)
我会使用insert . . . select
(个人偏好),但问题是子查询缺少额外的括号:
insert into TP1_PROPRIETAIRE_T
select 9654255475, 'Mike Ross',
TP1_PARTENAIRE_NT(TP1_PARTENAIRE('Andre Ross')),
TP1_CAPROPRO_NT(TP1_CAPROPRO( (select ref(p)
from TP1_PROPRIETE_T p
where p.NO_PROPRIETE = 1465798654
)
))
from dual;