Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL NATURAL Datatype      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: NATURAL

Definition:
In Oracle PL/SQL, NATURAL is a 32 bit sub datatype derived from BINARY_INTEGER. It allows positive integers or NULL values. (To prevent the assigning of nulls to an integer variable, use NATURALN or POSITIVEN.)

Note that NATURAL is a PL/SQL number type and cannot be used in SQL.

Example Usage:

The PL/SQL block below shows that the NATURAL variable cannot contain negative values.

SQL> DECLARE
L_NUM NATURAL;
BEGIN
L_NUM := -1;
END;
/
DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 4


The PL/SQL block below shows how NATURAL can be assigned with NULL and positive numbers only.

DECLARE
L_NUM1 NATURAL;
L_NUM2 NATURAL;
BEGIN
L_NUM1 := 10;
L_NUM2 := NULL;
END;
/

PL/SQL procedure successfully completed.


Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 191 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?