USING APEX_ERROR NOTIFICATIONS TO MANAGE CUSTOM ERROR MESSAGES

Include User
Notifications or Custom Messages and Error Messages in Oracle APEX’s default
Success and Error Message style. 



Default
Success message
:

Default Error
message
:

Steps in
APEX
:
ü  Step 1 : Create a text field item P11_ENAME.


Step 2 : Create a File Browse Item
P11_FILE_BROWSE and change the Storage Type as APEX_APPLICATION_TEMP_FILES
and Change the Purge File at End of Session.


APEX
Screen
:


ü  Step 3 : Create an Application Process Insert
Image and copy the below code as source.
Code :
        
DECLARE
   v_blob     
BLOB;
   v_emp_cnt  
NUMBER;
   v_name     
VARCHAR2 (100);
   v_sno      
NUMBER;
BEGIN
   BEGIN
      SELECT blob_content, NAME
        INTO v_blob, v_name
        FROM apex_application_temp_files
       WHERE ID = (SELECT MAX (ID)
                     FROM
apex_application_temp_files);
   EXCEPTION
      WHEN OTHERS
      THEN
         raise_application_error (-20038,
‘Table’);
   END;
   BEGIN
      SELECT NVL (MAX (sno), 0) + 1
        INTO v_sno
        FROM emp_files;
   –RAISE_APPLICATION_ERROR(-20034,v_sno);
   END;
   BEGIN
      IF :p11_empno IS NOT NULL
      THEN
         BEGIN
            SELECT COUNT (1)
              INTO v_emp_cnt
              FROM emp123
             WHERE empno = :p11_empno;
            IF v_emp_cnt = 1
            THEN
               BEGIN
                  INSERT INTO emp_files
                              (sno, empno, file_name, blob_content
                              )
                       VALUES (v_sno,
:p11_empno, v_name, v_blob
                              );
                  COMMIT;
                
apex_application.g_print_success_message :=
                        ‘<span
style=”color : white “>Success :</span>’
                     || TRIM (:p11_empno);
               EXCEPTION
                  WHEN OTHERS
                  THEN
                     raise_application_error
(-20098,
                                             
SQLERRM || ‘-‘ || ‘INSIDE’
                                             );
               END;
            ELSE
               /*  apex_application.g_print_success_message :=
                       ‘<span
style=”color : white “>Error in Uploading Image for Employee
:</span>’
                    || TRIM (:p11_empno);*/
               apex_error.add_error
                   (p_message               =>    ‘Employee No : ‘
                                               || :p11_empno
                                              
|| ‘ already exists.’,
                    p_display_location      => apex_error.c_inline_in_notification
                   );
            END IF;
         END;
      ELSE
         apex_error.add_error
                   (p_message               => ‘No value in the Employee
number field.’,
                    p_display_location      => apex_error.c_inline_in_notification
                   );
      END IF;
   END;
END;
Note : Above code contains two packages. apex_application.g_print_success_message for
Success and apex_error.add_error  for Error
Messages. You can change the Message info based on the requirement.

My Custom
Success Message
:

My Custom
Error Message
: I
have passed the Employee Number in to the Error Notification.

  • September 24, 2018 | 19 views
  • Comments