Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask PL-SQL Expert

Number Types

The Number types permit you to store the numeric data (real numbers, integers, and floating-point numbers), show quantities, and do computations.

BINARY_INTEGER

You use the BINARY_INTEGER datatype to store the signed integers. Its magnitude ranges from -2147483647 to 2147483647. Like PLS_INTEGER values, BINARY_INTEGER values need less storage than NUMBER values. Though, most BINARY_INTEGER operations are slower than the PLS_INTEGER operations.

BINARY_INTEGER Subtypes

A base type is the datatype from which a subtype is derived. A subtype links a base type with a constraint and so defines a subset of the values. For your convenience, the PL/SQL predefines the following BINARY_INTEGER subtypes as shown below:

NATURAL

NATURALN

POSITIVE

POSITIVEN

SIGNTYPE

The subtypes NATURAL & POSITIVE restrict an integer variable to non-negative or positive values, respectively. The NATURALN and POSITIVEN prevent the assigning of nulls to an integer variable. The SIGNTYPE restrict an integer variable to the values -1, 0, and 1, which is useful in the programming tri-state logic.

NUMBER

You use the NUMBER datatype to store a fixed-point or floating-point numbers of virtually any sizes. Its magnitude range is 1E-130 to 10E125. If the value of an expression falls exterior to this range, you get a numeric overflow or underflow error. You can specify the precision that is the total number of digits, and the scale, which is the number of digits to the right of the decimal point. The syntax is as shown below:

NUMBER[(precision,scale)]

To declare a fixed-point numbers, for which you must specify the scale, use the form as shown:

NUMBER(precision,scale)

To declare a floating-point numbers, for which you cannot identify the precision or scale as the decimal point can "float" to any position, use the form as shown:

NUMBER

To declare the integers, that have no decimal point, use the form sown below:

NUMBER(precision) -- same as NUMBER(precision,0)

You cannot use the constants or variables to specify the precision and scale; you should use the integer literals. The highest precision of a NUMBER value is 38 decimal digits. If you do not specify the precision, it default to 38 or the highest supported by your system, either is less.

NUMBER Subtypes

You can use the NUMBER subtypes for compatibility with ANSI/ISO and IBM types or when you want a more expressive name:

DEC

DECIMAL

DOUBLE PRECISION

FLOAT

INTEGER

INT

NUMERIC

REAL

SMALLINT

Use the subtypes DEC, DECIMAL, & NUMERIC to declare the fixed-point numbers with a greatest precision of 38 decimal digits.

Use the subtypes DOUBLE PRECISION & FLOAT to declare the floating-point numbers with a greatest precision of 126 binary digits, which is roughly equal to 38 decimal digits. Or, use the subtype REAL to declare a floating-point numbers with a greatest precision of 63 binary digits, which is roughly equal to 18 decimal digits.

Use the subtypes INTEGER, INT, & SMALLINT to declare integers with a greatest precision of 38 decimal digits.

PLS_INTEGER

You use the PLS_INTEGER datatype to store the signed integers. Its magnitude ranges from

2147483647 to 2147483647. The PLS_INTEGER values need less storage than NUMBER values. The PLS_INTEGER operations also use the machine arithmetic; therefore they are faster than NUMBER & BINARY_INTEGER operations that use library arithmetic. For superior performance, use PLS_INTEGER for all computations that fall within its magnitude range.

Though PLS_INTEGER and BINARY_INTEGER have the same magnitude range, they are not fully compatible. If a PLS_INTEGER computations overflows, an exception is raised. However, if  a BINARY_INTEGER calculation overflows, no exception is raised if the result is assigned to a NUMBER variable.Number Types

The Number types permit you to store the numeric data (real numbers, integers, and floating-point numbers), show quantities, and do computations.

BINARY_INTEGER

You use the BINARY_INTEGER datatype to store the signed integers. Its magnitude ranges from -2147483647 to 2147483647. Like PLS_INTEGER values, BINARY_INTEGER values need less storage than NUMBER values. Though, most BINARY_INTEGER operations are slower than the PLS_INTEGER operations.

BINARY_INTEGER Subtypes

A base type is the datatype from which a subtype is derived. A subtype links a base type with a constraint and so defines a subset of the values. For your convenience, the PL/SQL predefines the following BINARY_INTEGER subtypes as shown below:

NATURAL

NATURALN

POSITIVE

POSITIVEN

SIGNTYPE

The subtypes NATURAL & POSITIVE restrict an integer variable to non-negative or positive values, respectively. The NATURALN and POSITIVEN prevent the assigning of nulls to an integer variable. The SIGNTYPE restrict an integer variable to the values -1, 0, and 1, which is useful in the programming tri-state logic.

NUMBER

You use the NUMBER datatype to store a fixed-point or floating-point numbers of virtually any sizes. Its magnitude range is 1E-130 to 10E125. If the value of an expression falls exterior to this range, you get a numeric overflow or underflow error. You can specify the precision that is the total number of digits, and the scale, which is the number of digits to the right of the decimal point. The syntax is as shown below:

NUMBER[(precision,scale)]

To declare a fixed-point numbers, for which you must specify the scale, use the form as shown:

NUMBER(precision,scale)

To declare a floating-point numbers, for which you cannot identify the precision or scale as the decimal point can "float" to any position, use the form as shown:

NUMBER

To declare the integers, that have no decimal point, use the form sown below:

NUMBER(precision) -- same as NUMBER(precision,0)

You cannot use the constants or variables to specify the precision and scale; you should use the integer literals. The highest precision of a NUMBER value is 38 decimal digits. If you do not specify the precision, it default to 38 or the highest supported by your system, either is less.

NUMBER Subtypes

You can use the NUMBER subtypes for compatibility with ANSI/ISO and IBM types or when you want a more expressive name:

DEC

DECIMAL

DOUBLE PRECISION

FLOAT

INTEGER

INT

NUMERIC

REAL

SMALLINT

Use the subtypes DEC, DECIMAL, & NUMERIC to declare the fixed-point numbers with a greatest precision of 38 decimal digits.

Use the subtypes DOUBLE PRECISION & FLOAT to declare the floating-point numbers with a greatest precision of 126 binary digits, which is roughly equal to 38 decimal digits. Or, use the subtype REAL to declare a floating-point numbers with a greatest precision of 63 binary digits, which is roughly equal to 18 decimal digits.

Use the subtypes INTEGER, INT, & SMALLINT to declare integers with a greatest precision of 38 decimal digits.

PLS_INTEGER

You use the PLS_INTEGER datatype to store the signed integers. Its magnitude ranges from

2147483647 to 2147483647. The PLS_INTEGER values need less storage than NUMBER values. The PLS_INTEGER operations also use the machine arithmetic; therefore they are faster than NUMBER & BINARY_INTEGER operations that use library arithmetic. For superior performance, use PLS_INTEGER for all computations that fall within its magnitude range.

Though PLS_INTEGER and BINARY_INTEGER have the same magnitude range, they are not fully compatible. If a PLS_INTEGER computations overflows, an exception is raised. However, if  a BINARY_INTEGER calculation overflows, no exception is raised if the result is assigned to a NUMBER variable.

PL-SQL, Programming

  • Category:- PL-SQL
  • Reference No.:- M9509894

Have any Question?


Related Questions in PL-SQL

Assignment - queries functions and triggersaimthe aims of

Assignment - Queries, Functions and Triggers Aim The aims of this assignment are to: formulate SQL queries; populate an RDBMS with a real dataset, and analyse the data; design test data for testing SQL queries; create SQ ...

Continuing the project you have worked on in weeks 1-4 in

Continuing the project you have worked on in Weeks 1-4, in this final week, complete the following tasks: Refine your database and SQL statements by incorporating your instructor's feedback. Verify that the database comp ...

For this assignment you will be provided a database backup

For this assignment, you will be provided a database backup for a database called FinanceDB. You will have to restore this backup to your own version of SQL Server. All of the questions in this assignment relate to the F ...

Complete the following tasksin microsoft access create the

Complete the following tasks: In Microsoft Access, create the database and tables that you identified in W3 Assignment 2. In Microsoft Word, write the SQL statements to create the database and tables. Write SQL statement ...

Purpose of the assessment with ulo mapping the purpose of

Purpose of the assessment (with ULO Mapping) The purpose of this assignment is to develop skills in managing data in databases and to gain understanding of data model development and implementation using a commercially a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As