Skip to Main Content
  • Server-side multi row validations

Bredcrumb

Info

Set validation type to "all rows"

Enable Load all rows and Process all rows, to make sure the validation procedure sees all rows.

The sum of the values in "pct" needs to add up to 100. (note that on a success you will see the error message "invalid table name" as this queries from dual)

code of the validation procedure
PROCEDURE validate_pct_sum_is_100(p_crud_requests IN OUT NOCOPY UC_GRID_CRUD_REQUEST_TT)
as
    l_crud_request UC_GRID_CRUD_REQUEST_T;
    l_pct_sum number := 0;
    l_pct     number;
begin
    apex_debug.info('validate_pct_sum_is_100');
    apex_debug.info('Rows: ' || p_crud_requests.count);


    for i in p_crud_requests.first .. p_crud_requests.last
    loop
        l_crud_request := p_crud_requests(i);
        l_pct := l_crud_request.get_value('PCT');

        l_pct_sum := l_pct_sum + l_pct;
    end loop;

    apex_debug.info('PCT sum: ' || l_pct_sum);

    if l_pct_sum != 100 then
        for i in p_crud_requests.first .. p_crud_requests.last
        loop
            -- only add exceptions to changed rows
            if p_crud_requests(i).crud_request is not null then
                p_crud_requests(i).add_exception(
                    p_column_name    => 'PCT'  
                   ,p_exception_text => 'All Percent values have to add up to 100'
                ); 
            end if;
        end loop;
    end if;
end validate_pct_sum_is_100;
        

% needs to add up to 100