I am trying to insert a ref in a nested table but I keep getting the error SQL Error: ORA-00936: missing expression
The relevant types and tables are as follows:
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));
/
And here are the inserts:
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)));
/
I get the following error when executing the last insert:
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:
From what I have read from SO and other forums, the error is most likely somewhere in the last select ref(p)... but the syntax seems fine to me, so I really don't know why I get this error. Thanks for your time.
I would use insert . . . select
insert . . . select
insert . . . select
(personal preference), but your problem is the lack of extra parentheses for the subquery:
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.