Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I declare a variable type number with precision of 127?

User_TDDEPJun 25 2015 — edited Jun 25 2015

I try to declare a variable with precision - just like for example V_NUM NUMBER(1,127);.

According to oracle it should be possible -

http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements001.htm#SQLRF30020

2

NUMBER [ (p [, s]) ]

Number having precision p and scale s. The precision p can range from 1 to 38. The scale s can range from -84 to 127. Both precision and scale are in decimal digits. A NUMBER value requires from 1 to 22 bytes.

but after execution of this

declare

  V_NUM number (1,127);

begin

  V_NUM:=1.2333333333333333333333234343435;

  DBMS_OUTPUT.PUT_LINE(V_NUM);

end;

/

i got error (I know p should be greater then s - but I cant figured out an example for this case s=127)

Error starting at line : 1 in command -

declare

  V_NUM number (1,127);

begin

  V_NUM:=1.2333333333333333333333234343435;

  DBMS_OUTPUT.PUT_LINE(V_NUM);

end;

Error report -

ORA-06502: PL/SQL: numeric or value error: number precision too large

ORA-06512: at line 4

06502. 00000 -  "PL/SQL: numeric or value error%s"

*Cause:    An arithmetic, numeric, string, conversion, or constraint error

           occurred. For example, this error occurs if an attempt is made to

           assign the value NULL to a variable declared NOT NULL, or if an

           attempt is made to assign an integer larger than 99 to a variable

           declared NUMBER(2).

*Action:   Change the data, how it is manipulated, or how it is declared so

           that values do not violate constraints.

Is this possible to achive my target?

This post has been answered by User_TDDEP on Jun 25 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 23 2015
Added on Jun 25 2015
9 comments
2,172 views