macwadu
macwadu

Reputation: 907

apex_application.g_notification

I'm trying to do a notification message when doing a process on submit but is not working

DECLARE

l_sendto NUMBER := :P22_SEND_TO;
l_user_groups NUMBER := :P22_USER_GROUP;
l_media NUMBER := :P22_MEDIA;
l_usersessionid NUMBER := :APP_SESSION;
SINGLE_USER CONSTANT number :=0;
l_aux NUMBER;

e EXCEPTION;

BEGIN
--verify if user 
select userid into l_aux FROM SURV_TEMP_SENDTO WHERE userid = l_user_groups and usersessionid= l_usersessionid and rownum =1;

IF l_aux > 0 THEN
  RAISE e;
ELSE     
  IF l_sendto = SINGLE_USER THEN
     --if selected all types of medias of one user    
        INSERT INTO SURV_TEMP_SENDTO (userid, mediatypeid, usersessionid)
                (SELECT zm.userid, zm.mediatypeid, l_usersessionid  
                  FROM z.media zm, Z.media_type zmt 
                  WHERE zmt.mediatypeid = zm.mediatypeid 
                  AND zm.userid = l_user_groups);
    apex_application.g_print_success_message := 'Inserting OK';
END IF;

EXCEPTION
   WHEN e THEN
    apex_application.g_global_notification:= 'Error inserting values';
    --apex_application.g_print_success_message := 'Error inserting values';
END;

In the raise EXCEPTION it doesn't show any msg but if he enters the ELSE it writes the success msg.

Anyone know why it doesn't work in EXCEPTION?

Upvotes: 2

Views: 9439

Answers (1)

Tony Andrews
Tony Andrews

Reputation: 132580

In the ELSE you are using g_print_success_message. That will work in the EXCEPTION section too. When I tried it, g_global_notification didn't work in either main body or exception section, but only appeared if an exception was raised and not handled - I don't know why though.

Upvotes: 1

Related Questions