Given this code (pseudo)
MERGE INTO ...
(SELECT ... FROM ...) ...
ON (...)
WHEN NOT MATCHED THEN
INSERT (...) VALUES (...);
//This is Oracle Apex code
apex_application.g_unrecoverable_error := true;
htp.init();
owa_util.redirect_url('f?p=111:11:&APP_SESSION.::NO:::');
How would add a condition so that when it doesn’t match it, I need to run this line of code:
apex_application.g_notification := 'My error';
I am not sure what to do to make it work. I tried some ELSE and additional WHEN statements but it doesn’t seem to work.
As far as I am aware you will not be able to extend the MERGE statement in this way. You can take a count of of table being inserted into before and after to determine whether any rows fell into the NOT MATCHED section and got inserted.
Put your logic in an IF statement using that count.