Stack Exchange
how to resolve this type of error when inserting a new row in a table?
CREATE OR REPLACE TYPE hypothesis AS TABLE OF VARCHAR2(20);
/
CREATE OR REPLACE TYPE Hypoth_pr AS OBJECT (prob_content VARCHAR2(20), pr NUMBER);
/
CREATE OR REPLACE TYPE Hypoth_po AS OBJECT (possib_content VARCHAR2(20), po NUMBER);
/
CREATE OR REPLACE TYPE focal_element AS OBJECT(focal_element_content hypothesis, focal_element_mass NUMBER);
/
CREATE OR REPLACE  TYPE bba AS TABLE OF focal_element;
/
CREATE OR REPLACE TYPE Pr_Dist AS TABLE OF Hypoth_pr;
/
CREATE OR REPLACE TYPE po_Dist AS TABLE OF Hypoth_po;
/
CREATE OR REPLACE TYPE confidence_level AS OBJECT(bel NUMBER, pl NUMBER);
/
CREATE TABLE edb (pid VARCHAR2(10) PRIMARY KEY, Disease bba, Symptom Pr_Dist, Age po_Dist, cl CONFIDENCE_LEVEL)
NESTED TABLE Disease STORE AS Diseases (NESTED TABLE focal_element_content STORE AS focal_element_contents_fs),
NESTED TABLE Symptom STORE AS Symptoms
NESTED TABLE Age STORE AS Ages;
/
INSERT INTO edb VALUES ('2', bba(focal_element(hypothesis('Pneumonia',0.2)), focal_element(hypothesis('Cold','Fever'),0.6)),
pr_Dist(Hypoth_pr('Cough',0.5), Hypoth_pr('Headcaches',0.5)),
po_Dist(Hypoth_po('Old',1), Hypoth_po('Teenager',0.7)), 
CONFIDENCE_LEVEL(0.4,0.8));


Erreur à la ligne de commande: 26 Colonne: 34
  Rapport d'erreur -
  Erreur SQL : ORA-02315: nombre d'arguments non valide pour constructeur par défaut
  02315. 00000 -  "incorrect number of arguments for default constructor"
  *Cause:    The number of arguments specified for the default constructor
             doesn't match the number of attributes of the object type.
  *Action:   Specify the correct number of arguments for the default
             constructor and retry the operation.


You wanted to use double focal_element for bba, but using redundant closing parentheses for the first one corrupts the syntax as focal_element(hypothesis('Pneumonia')   ,0.2))
                                                                        -->^
Try Insert statement below :
INSERT INTO edb VALUES ('2', 
bba(focal_element(hypothesis('Pneumonia')   ,0.2), 
    focal_element(hypothesis('Cold','Fever'),0.6) ),
pr_Dist(Hypoth_pr('Cough',0.5), Hypoth_pr('Headcaches',0.5)),
po_Dist(Hypoth_po('Old',1), Hypoth_po('Teenager',0.7)), 
CONFIDENCE_LEVEL(0.4,0.8));


he showed me this error:  'Erreur commençant à la ligne: 31 de la commande -
INSERT INTO edb VALUES ('2',
bba(focal_element(hypothesis('Pneumonia')   ,0.2),
focal_element(hypothesis('Cold','Fever'),0.6) ),
pr_Dist(Hypoth_pr('Cough',0.5), Hypoth_pr('Headcaches',0.5)),
po_Dist(Hypoth_po('Old',1), Hypoth_po('Teenager',0.7)),
CONFIDENCE_LEVEL(0.4,0.8))
Rapport d'erreur -
ORA-00001: violation de contrainte unique (SYSTEM.SYS_C0011499) '

@DORRAAMRI notice that the error message changed, and that suggests obviously the insert operation is violating the unique constraint on pid column. E.g. your issue is resolved. Just convert '2' to a diferent value which not yet been inserted into edb.

Thank you, the problem is solved. But, but when I apply the query "select * from edb;" it shows me like that, instead of showing me a table.

you're welcome @DORRAAMRI . I didn't understand the part after "but" ...

PID
DISEASE
SYMPTOM(PROB_CONTENT, PR)
AGE(POSSIB_CONTENT, PO)
PID
DISEASE
SYMPTOM(PROB_CONTENT, PR)
AGE(POSSIB_CONTENT, PO)
2
BBA(FOCAL_ELEMENT(HYPOTHESIS('Pneumonia'), 0,2), FOCAL_ELEMENT(HYPOTHESIS('Cold',
PID
DISEASE
SYMPTOM(PROB_CONTENT, PR)
AGE(POSSIB_CONTENT, PO)

you should be seeing disease, symptom and age fields as collection, and pid = 2, cl.bel=0,4, cl.pl=0,8 @DORRAAMRI

you can use treat function to query object type such as select pid, treat(cl AS confidence_level).bel from edb
