Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Send mail using APEX_MAIL.SEND in trigger

Marco FoxxOct 4 2018 — edited Oct 24 2018

Version : 18.1 Database 11gr2/12c

I need to send a mail only when any changes occurs in database table.

Explanation : I need to send a mail if customer's email id or any other information gets updated into the table(form based page).For this i have created a DEMO on AOC using DEMO_CUSTOMERS table in which i have created a simple triggers which should send a mail only if any changes occurs else it should not. But it gives me an error stating "can not in trigger". If any one can correct me if this possible or not.

Sample database application > customer > edit customer information  > apply change.(its a form based on demo_customers table in which i have created below trigger)

trigger snippet:

CREATE OR REPLACE TRIGGER send_mail_DEMO_CUSTOMERS

AFTER UPDATE

   ON DEMO_CUSTOMERS

   FOR EACH ROW

DECLARE

  

   v_workspace_id number;

   v_from_email varchar2(100) :='abc@gmail.com';

BEGIN

  SELECT workspace_id

    INTO v_workspace_id

    FROM apex_applications

    WHERE application_id = 1234;

    apex_util.set_security_group_id(v_workspace_id);

    apex_application.g_flow_id  := 1234;

APEX_MAIL.SEND( P_TO        => v_from_email ,

                P_bcc       => NULL,

                P_FROM      => v_from_email,

                P_BODY      => 'Hi',

                P_BODY_HTML => 'hi',

                P_SUBJ      => 'Welcome');

APEX_MAIL.PUSH_QUEUE; 

END;

Comments
Post Details
Added on Oct 4 2018
11 comments
5,618 views