I'm new to MERGE statements and I'm wondering if it is possible to return a value from either the MATCHED or NOT MATCHED portion of one of them.
I have a dumbed down example below:
MERGE INTO USERS
USING (SELECT FIRST_NAME, LAST_NAME, EMAIL
WHERE USERNAME = pUsername)
ON (USERS.USERNAME = pUsername)
WHEN MATCHED THEN
FIRST_NAME = pFName,
LAST_NAME = pLName,
EMAIL = pEmail
WHEN NOT MATCHED THEN
INSERT (ID, FIRST_NAME, LAST_NAME,
EMAIL, ENTRY_BY, ENTRY_DATE,
VALUES (pId, pFName, pLName,
pEmail, pUsername, SYSDATE, pUsername);
What I would like to do is return a NUMBER from both of the conditions...a 1 for the MATCH and a 0 for the NOT MATCHED to keep it simple.