Search code examples
oracle-databaseplsqlsubtype

oracle PL SQL positive number subtype


I want to create a positive number(6, 2) subtype. For this, I tried:

declare
    subtype st_positive_number is number(6, 0) > 0;
    v_positive_number positive(6, 2);
begin 
    null;
end;

but none of the above tries works. Can someone help, please?


Solution

  • You need to constrain the subtype with a range and you want to assign that subtype to the variable, e.g.:

    declare
        subtype st_positive_number is PLS_INTEGER RANGE 0..999999;
        v_positive_number st_positive_number;
    begin 
        v_positive_number := 999999;
    end;
    /