0
votes

I have done page validations in oracle apex to different items present in the page but when I click submit button, all the validations run at a time.

Means, suppose I have 3 rows and I have done separate validations on those rows like if I do something only in row 1 then after submitting the validation should show only for row 1 when I don't touch the other two rows.

But what's happening is all the rows validation errors are showing at once after submitting.

Please help regarding this.

1
Please include a mvce - leonardkraemer
(1) Apex have server side conditions to say when something should execute or not. (2) You can use a pl/sql function to validate, so you can test more than one thing to validate. Ex. test first if is null and after test other thing. - romeuBraga

1 Answers

0
votes
declare

    v_amt number;
    v_disc number;
    v_flat_amt number;
    v_EXP_DATE DATE;
    v_disc_type varchar2(1);
begin
    select sum(c002 * c003) into v_amt
    from apex_collections
    where collection_name = 'items'
    and c003 <> 0;
    select sv.DISCOUNT_PREC, sv.FLAT_DISCOUNT_AMOUNT, cv.VOUCHER_ID, SV.EXPIRY_DATE,DISCOUNT_TYPE
    INTO v_disc, v_flat_amt, :P_VOUCHER_ID,v_EXP_DATE,v_disc_type
    from CUSTOMER_VOUCHERS cv, SALE_VOUCHERS sv
    WHERE CV.VOUCHER_ID = sv.ID
    AND CV.CUST_ID = :GLOBAL_CUSTOMER_ID
    AND PROMO_CODE=:P_VOUCHER_CODE
    AND NVL(AVAILED,'N')='N';

    if trunc(v_EXP_DATE) < trunc(sysdate) then
        :P13_DISC_PERC :=NULL;
        :P13_VOUCHER_ID:=NULL;
        APEX_ERROR.ADD_ERROR (
        p_message => v_EXP_DATE||'This is has been expired.',
        p_display_location => apex_error.c_inline_in_notification);
    end if;
    if v_disc_type = 'P' then
        :P13_DISC_PERC := round(v_amt*v_disc/100);
    else
        if v_flat_amt > v_amt then
            :P13_DISC_PERC := v_amt;
        else
            :P13_DISC_PERC := v_flat_amt;
        end if;
    end if;
    exception when no_data_found then
        :P_DISC_PERC :=NULL;
        :P_VOUCHER_ID:=NULL;
        APEX_ERROR.ADD_ERROR (
        p_message => 'Voucher not found.',
        p_display_location => apex_error.c_inline_in_notification);
end;