user13768246
user13768246

Reputation:

Oracle Apex. Is it possible to Ignore Process on Error?

Is it possible to ignore a process if that process does not work?
I have a process that sends an email when the user clicks the Create button on my page. But the problem is that I can send up to 50 emails per day for security reasons. If the user exceeds 50 emails, this process displays an error and stops. So I can not save the new record. Is it possible on error to ignore this process and continue to save the new record?

Upvotes: 1

Views: 497

Answers (1)

Valério Costa
Valério Costa

Reputation: 435

Create an exception "when others" that will ignore any error

for example

declare
    l_id number;
begin
l_id := apex_mail.send(
    p_to        => '[email protected]',
    p_from      => '[email protected]',
    p_subj      => 'APEX_MAIL with attachment',
    p_body      => 'Please review the attachment.',
    p_body_html => '<b>Please</b> review the attachment');

for c1 in (select filename, blob_content, mime_type 
    from apex_application_files
    where id in (123,456)) loop

    apex_mail.add_attachment(
        p_mail_id    => l_id,
        p_attachment => c1.blob_content,
        p_filename   => c1.filename,
        p_mime_type  => c1.mime_type);
    end loop;
commit;

exception
    when others 
    then
        rollback;
        null;
end;

Upvotes: 2

Related Questions