Definition:
In Oracle PL/SQL, POSITIVE is a 32 bit sub datatype derived from BINARY_INTEGER. It allows only positive integers which may also be NULL.
Note that POSITIVE is a PL/SQL number type and cannot be used in SQL.
Example Syntax:
VARIABLE [POSITIVE]
Example Usage:
The PL/SQL block below declares two POSITIVE variables. Note that L_NUM1 allows a NULL assignment while other one is assigned as 10.
DECLARE
L_NUM1 POSITIVE;
L_NUM2 POSITIVE;
BEGIN
L_NUM1 := NULL;
L_NUM2 := 10;
END;
PL/SQL procedure successfully completed.
The PL/SQL block below declares a POSITIVE variable and assigns a negative value to it. Oracle raises the exception ORA-06502: numeric value error. This demonstrates the exclusion of negative values in POSITIVE variables.
DECLARE
L_NUM POSITIVE;
BEGIN
L_NUM := -10;
END;
SQL> /
DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 4
Related Links: