I am trying to insert some data inside a view which contains columns from two tables. The problem is that I recieve the error:
SQL Error: ORA-01779: cannot modify a column which maps to a non key-preserved table
This is my code:
CREATE VIEW testvizualizare AS
SELECT
F.id_formatie, F.nume nume_formatie, F.data_lansare, F.tara_prov,
A.data_l, A.gen, A.id_album, A.id_formatie id_formatie_album, A.nume nume_album, A.pret
FROM
formatie F JOIN album A ON(F.id_formatie = A.id_formatie)
JOIN castiga C ON (C.id_formatie = A.id_formatie)
JOIN premiu P ON(P.id_premiu = C.id_premiu)
WHERE
EXISTS(
SELECT
1
FROM
formatie F1 JOIN album A1 ON(F1.id_formatie = A1.id_formatie)
JOIN castiga C1 ON (C1.id_formatie = A1.id_formatie)
JOIN premiu P1 ON(P1.id_premiu = C1.id_premiu)
WHERE
f1.id_formatie = F.id_formatie AND LOWER(a1.gen) = 'pop');
INSERT INTO testvizualizare
VALUES(100, 'Atmosphere', (SELECT TO_DATE('01011996', 'DDMMYYYY') FROM DUAL), 'USA', (SELECT TO_DATE('06052014', 'DDMMYYYY') FROM DUAL), 'Hip-Hop', 999, 100, 'Southsiders', 15);
I guess that the problem is the join. I creating two inserts each for each table (F and A). I also tried removing A.id_formatie
, but with no luck.
Any help is appreaciated! Thanks.