What data types can I use the Oracle PL / SQL RANGE clause to limit a variable?

I am trying to figure out when the use of the RANGE clause is permitted in the definition of a variable in the declarative section of a PL / SQL block.

The following code has been tested on Oracle 12c

It works...

declare
   l_constrained  PLS_INTEGER  RANGE  7..10 ;
begin
   l_constrained := 9;
end ;
/

This gives a compilation error ...

declare
   l_constrained  NUMBER(2)  RANGE  7..10 ;
begin
   l_constrained := 9;
end ;
/

This seems to work only when applied to PL / SQL data types, not SQL data types, but this is just my first impression.

Can someone please give me some information and perhaps lead me in the official Oracle documentation covering the use of the RANGE clause? I can not find him...

+4
source share
1

.

, , -, " " PLS_INTEGER .

, , PLS_INTEGER ( , ).

https://docs.oracle.com/database/121/LNPLS/datatypes.htm#CHDBBCIE

RANGE , , - , NUMBER(8,2), .

+3

Source: https://habr.com/ru/post/1619650/


All Articles