Oracle从多个表中删除行

时间:2018-09-26 20:16:13

标签: sql oracle plsql

我正在尝试从多个表中删除行,但是在medewerkers m上出现语法错误,

有人可以告诉我我在做什么错吗? :

declare
v_mnr medewerkers.mnr%type;
procedure ontsla_med(p_mnr in medewerkers.mnr%type)
IS
BEGIN
    DELETE FROM medewerkers m, INSCHRIJVINGEN i , UITVOERINGEN u WHERE m.MNR = p_mnr and i.cursus = p_mnr and u.docent = p_mnr;
END ontsla_med;
BEGIN
    ontsla_med(7000);
END;

好像删除语句是错误的?

1 个答案:

答案 0 :(得分:4)

无法做到。它必须是三个单独的删除。

DELETE 
  FROM medewerkers
 WHERE mnr = p_mnr;

DELETE 
  FROM UITVOERINGEN 
 WHERE cursus = p_mnr;

DELETE 
  FROM UITVOERINGEN 
 WHERE docent = p_mnr;