P
P
pola_pumpkin2020-12-08 23:22:25
Oracle
pola_pumpkin, 2020-12-08 23:22:25

How to update values?

Hi, can't update REF values.
Apparently I do not fully understand how UPDATE works in OOBD.
Who can tell what is wrong?

CREATE OR REPLACE TYPE T_STUDENT AS OBJECT(
    S_NUM   INT,
    S_UZV   VARCHAR2(30)
);

CREATE OR REPLACE TYPE T_PASN AS OBJECT(
    P_NUM   INT,
    P_UZV   VARCHAR2(30)
);

CREATE OR REPLACE TYPE S_ATS AS OBJECT(
    STUD_ATS REF T_STUDENT
);

CREATE OR REPLACE TYPE P_ATS AS OBJECT(
    PASN_ATS REF T_PASN
);

CREATE OR REPLACE TYPE K_STUD AS TABLE OF S_ATS;

CREATE OR REPLACE TYPE K_PASN AS TABLE OF P_ATS;

CREATE OR REPLACE TYPE O_STUDENT AS OBJECT(
    STUD T_STUDENT,
    PASN K_PASN
);

CREATE OR REPLACE TYPE O_PASN AS OBJECT(
    PASN T_PASN,
    STUD K_STUD
);

CREATE TABLE STUDENTI OF O_STUDENT
NESTED TABLE PASN STORE AS PASN_TBL;

CREATE TABLE PASNEDZEJI OF O_PASN
NESTED TABLE STUD STORE AS STUD_TBL;

-------------------------------------

INSERT INTO STUDENTI VALUES(T_STUDENT(58912, 'GUSEVS'), NULL);

INSERT INTO PASNEDZEJI VALUES(T_PASN(12, 'MILANOVSKIS'),NULL);

INSERT INTO PASNEDZEJI VALUES(T_PASN(13, 'GOMELEVS'), NULL);

SELECT REF(A) FROM PASNEDZEJI A WHERE A.PASN.P_NUM = 12; -- Для проверки

SELECT VALUE(A) FROM STUDENTI A WHERE A.STUD.S_NUM = 58912; -- Для проверки

UPDATE STUDENTI A SET A.PASN = (SELECT REF(A) FROM PASNEDZEJI A WHERE A.PASN.P_NUM = 12) WHERE A.STUD.S_NUM = 58912;


After UPDATE the following error occurs:
UPDATE STUDENTI A SET A.PASN = (K_PASN((SELECT REF(A) FROM PASNEDZEJI A WHERE A.PASN.P_NUM = 12))) WHERE A.STUD.S_NUM = 58912
Error at Command Line : 51 Column : 52
Error report -
SQL Error: ORA-00932: incompatible data types: USER.P_ATS expected, REF USER.O_PASN received

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question