I have to write a trigger to insert the data into the DB if doesn't exists. I wrote till inserting the records. I am doing signaling if the data is exists which is failing my entire batch of records.
My questions: Is there any keyword which will skip/ignore/discard the current row?
My trigger is below. I want to remove signal and keep something else which will
discard/ignore/skip the current row insertion. For example : Continue keyword in JAVA .
CREATE OR REPLACE TRIGGER tri_books_edit
NO CASCADE BEFORE INSERT ON books
REFERENCING NEW AS N
FOR EACH ROW
WHEN ((select count(*) from books where book_name = N.book_name and author = N.Author) > 0)
SIGNAL SQLSTATE '75000' SET MESSAGE_TEXT = 'Duplicate row with same name and author'
Thanks for your help
You don't need to use a trigger for this. Just add a unique index on the two fields:
Much simpler solution for preventing duplicates.