Skip to main content
Question

uncoherent behavior in custom event to catch history log


Forum|alt.badge.img+9

Hello All,

I have created a custom event to send an email to users and inform them of the (log id) when a field is updated or deleted in customer screen.

Here is my custom event script : 

DECLARE
    log_lu_name_       VARCHAR2(1000);
    log_id_            NUMBER := 0;
    customer_id_       VARCHAR2(1000);

BEGIN

    --Set general parameters
    customer_id_ := '&OLD:CUSTOMER_ID' ;
    log_lu_name_ := 'CustomerInfo';


    BEGIN

    --Get log ID for history log search
    SELECT max(log_id) into log_id_
    FROM   history_log 
    WHERE  lu_name = log_lu_name_
    AND    keys like ('%'|| customer_id_||'%')
    AND    UPPER(history_type) IN ('UPDATE' , 'DELETE')  ;

    command_sys.Mail(sender_ => 'IFS Applications!',
                     from_ => '&USER_EMAIL',
                     to_list_ => '&USER_EMAIL',
                     cc_list_ => '',
                     bcc_list_ => '',
                     subject_ => 'customer : '|| customer_id_ ,
                     text_ =>'log_id_ = ' || log_id_,
                     attach_ => '',
                     rowkey_ => '',
                     mail_sender_ => '');

END;
END;

and the result of the mail in application message : 


When I run the query separatly in sql query tool , I get this result :

 

The number sent in the mail is always delayed by 1, I don’t understand where is the issue.

Can you please help me figure it out ? 

 

Thank you in advance,

Hanane

2 replies

Forum|alt.badge.img+7
  • Sidekick (Employee)
  • 88 replies
  • June 28, 2024

@Hanane 

This is only a theory on my part….but if there were a database trigger in use with what you’re attempting to do here, and if the custom event you’ve described above is getting the old value (or value prior to a change or creation of log ID value) ….and the SELECT statement of the SQL Query Tool screen shot gets the Log ID value after the change or creation of latest Log ID…. this might account for the result you’ve shown above.


Forum|alt.badge.img+9
  • Author
  • Sidekick
  • 42 replies
  • July 2, 2024

Thank you, Eugene for your reply.

I have set the custom event to fire after the object is changed:

 

Do you have an idea how can I synchronize the two results? 

 

Thank you,

Hanane


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings