Guest User

Untitled

a guest
Jan 24th, 2020
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --#SET TERMINATOR @
  2. CREATE PROCEDURE HRISDIM.USP_SET_EMAIL_NOTIFICATION_SETTING(IN userKey DECIMAL(15, 0),
  3.                                                             IN emailNotificationSetting VARCHAR(30))
  4. P1:
  5. BEGIN
  6.     DECLARE userEntriesCount BIGINT;
  7.  
  8.     SELECT COUNT(CNS.ID)
  9.     INTO userEntriesCount
  10.     FROM HRISDIM.COMS_NOTIFICATION_SETTINGS CNS
  11.     WHERE CNS.USER_KEY = userKey;
  12.  
  13.     --If there is entry for that user key, update it, otherwise create new one.
  14.     IF userEntriesCount > 0 THEN
  15.         UPDATE HRISDIM.COMS_NOTIFICATION_SETTINGS
  16.         SET EMAIL_NOTIFICATION_TYPE = emailNotificationSetting
  17.         WHERE USER_KEY = userKey;
  18.     ELSE
  19.         INSERT INTO HRISDIM.COMS_NOTIFICATION_SETTINGS (USER_KEY, EMAIL_NOTIFICATION_TYPE)
  20.         VALUES (userKey, emailNotificationSetting);
  21.     END IF;
  22. END P1 @
RAW Paste Data