Oracle
 sql >> Database >  >> RDS >> Oracle

sql - inserisci se non esiste

Fai tutto in SQL anziché passare al contesto in PL/SQL:

INSERT INTO DATA1.FOLDERS
(folder_id,
 user_id)
SELECT f1.folder_id,
       f1.user_id
  FROM DATA1.FOLDERS f1
 WHERE NOT EXISTS (SELECT 1
                     FROM DATA1.FOLDERS f2
                    WHERE f1.folder_id = f2.folder_id
                      AND f1.user_id = f2.user_id);