NUMBER : Number « PL SQL Data Types « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » PL SQL Data Types » Number 
21. 14. 1. NUMBER

The NUMBER datatype is used for declaring both fixed-point and floating-point numbers.

The NUMBER datatype can be used to represent numbers in the range 1.0E-123 through 9.99E125.

The NUMBER datatype allows for up to 38 decimal digits of precision.

The Syntax for the NUMBER Datatype

variable_name NUMBER [(precision[,scale])]

variable_name is whatever name you want to give this variable.

precision specifies the number of decimal digits used to represent the value internally.

precision range is 1 to 38.

the default for precision rangeis 38.

scale indicates where the decimal point is and where rounding occurs.

The range for scale is -84 to 127, and the default is zero.

precision as telling you how many digits are used to represent the number.

scale tells you where the decimal point is.

Both precision and scale are optional.

The NUMBER datatype is overloaded to include three different numeric groups:

Integers ( NUMBER with only precision) are between -10^38 and 10^38 not including either of the bounds.

Fixed-point values (NUMBER both precision and scale) are between -10^122 and 10^122, not including either of the bounds and can be as small as 10^ C127.

Floating-point values (you don't specify anything) are between -10^130 and 10^130, not including either of the bounds and can be as small as 10^ C127.

For example,

dollar_amount NUMBER (5,2);
  1. The dollar_amount variable, defined as NUMBER(5,2), would be precise to five digits, two of which would be to the right of the decimal.
  2. All amounts would be rounded to the nearest hundredth.
  3. The dollar_amount variable could store values such as 123.45, -999.99, and so on.
  4. Assigning it a value of 123.456 would result in the value being rounded off to 123.46.
myNumber NUMBER (3);
  1. myNumber variable would take the default scale of zero.
  2. myNumber could store no digits to the right of the decimal.
  3. All values will be rounded to the nearest whole number.
  4. Assigning it a value of -123.45 would result in it being rounded off to -123.
myNumber2 NUMBER(5,-2);
  1. myNumber2 stores five digits of precision.
  2. All values are in hundreds.
  3. myNumber2 could store values ranging from 0 to 9,999,900, but all values would be rounded to the nearest hundred.
  4. Assign it a value of 100, and it will store 100.
  5. Assign it a value of 327, and it will be rounded off to 300.
  6. Why use a variable like this?
  7. It saves a bit of space and allows you to use the 38 digits to represent some very large numbers without making excessive demands on memory.
myNumber3 NUMBER (1,6)
  1. myNumber3 specified a scale that is larger than the precision.
  2. myNumber3 will store values of one millionth, two millionths, and so on up to nine millionths.
  3. All values will be rounded to the nearest millionth.
  4. If you assigned it a value of 0.00000016, you would get 0.0000002.
  5. Because the precision is only one, trying to assign a value of 0.000001 would result in an error.
21. 14. Number
21. 14. 1. NUMBER
21. 14. 2. NUMBER Subtypes
21. 14. 3. Identical declarations using NUMBER subtypes.
21. 14. 4. Number type variable
21. 14. 5. Assign value to NUMBER type variable
21. 14. 6. NATURAL value Computation
21. 14. 7. Assigning a Fraction to an Integer
21. 14. 8. Setting Precision and Scale
21. 14. 9. NUMBER(1,-2): Variable with a scale of -2 can only hold values like 100,200,300... up to 900.
21. 14. 10. NUMBER Data type: integer, fixed point and floating point
21. 14. 11. Select a number value from a table into a variable and output it
21. 14. 12. IF statement with number value check
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.