Thursday, 19 March 2015

Checking duplicates and positive number

1. Form

2.

declare
    chk_button number;
    xcount number;
begin
   
    --checking duplicates
    select count(*) into xcount from suplr_mstr where suplr_mstr.suplrid=:suplr_mstr.supLrid;
   
    if xcount <>0 then
        message('Enter supplier''s identity number');
        set_alert_property ('IO_ALERT', title, 'Primary Key Violation');
        set_alert_property ('IO_ALERT', alert_message_text, 'Supplier''s ID number already exist');
        chk_button:=show_alert('IO_ALERT');
        RAISE FORM_TRIGGER_FAILURE;
    END IF;

--checking filed if not greater than zero
   
    if not:suplr_mstr.supLrid>0 then
      message('Enter supplier''s identity number');
        set_alert_property ('BUSS_ALERT', title, 'Business Rule Violation');
        set_alert_property ('BUSS_ALERT', alert_message_text, 'Supplier''s ID should be positive integer');
        chk_button:=show_alert('BUSS_ALERT');
        RAISE FORM_TRIGGER_FAILURE;
    END IF;

END;


3. Output