I am trying to update all rows in my CASE table:
UPDATE CASE c
SET c.number =
(
select p.number
from CASE c, Papers p, Dokument d
where c.dokument = d.id
and p.id = d.paperid
and p.numer is not null
and c.case = null;
)
where
(this same as in set : when case.number is null but papers.numer is not null)
I can't do this because I don't know how to write where clauses. It must update all rows where case.numer
is null and papers.number
is not null.
How can I write this? Could I write some loop? I've never used PL/SQL so I don't know how to do that either.
I've also tried to update like this but got an error:
UPDATE s
SET s.number = w.number
FROM CASE s
JOIN Dokument d on d.CASEID =s.ID
JOIN Paper w on w.DOKUMENTID =d.ID and w.number is NOT NULL
WHERE s.number IS NULL
AND s.secondNumber IS NULL
AND s.FIRSTNAME = w.FIRSTNAME
AND s.SURNAME = w.SURNAME;
SQL Error: ORA-00933: polecenie SQL niepoprawnie zakończone
00933. 00000 - "SQL command not properly ended"