stummyhurts
stummyhurts

Reputation: 23

Number Limitation for Whole Number and Decimal Number for Oracle APEX

Is it possible to limit whole number and decimal number for an item in Oracle APEX?

Upvotes: 0

Views: 251

Answers (1)

Littlefoot
Littlefoot

Reputation: 142705

If "limit" means to set their minimum and maximum value, then yes - in item's properties:

enter image description here


As you commented, it is about number of characters. In that case, create a validation, e.g. function that returns error text such as

declare
  l_max_len_whole    number := 5;
  l_max_len_decimals number := 2;
  --
  l_len_whole        number;
  l_len_decimals     number;
begin
  l_len_whole    := length(regexp_substr(:P1_ITEM, '\d+'));

  l_len_decimals := case when :P1_ITEM = trunc(:P1_ITEM) then 0
                         else length(regexp_substr(:P1_ITEM - trunc(:P1_ITEM), '\d+$')
                    end;

  if l_len_whole > l_max_len_whole then
     return 'No more than ' || l_max_len_whole || ' whole digits';
  elsif l_len_decimals > l_max_len_decimals then
     return 'No more than ' || l_max_len_decimals || ' decimal digits';
  end if;
end;

Upvotes: 1

Related Questions