Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Number datatype help?
On Nov 19, 12:26 pm, "CK" <c_kettenb..._at_hotmail.com> wrote:
> New to Oracle. How can I declare a variable NUMBER that can be assigned:
>
> a. 654321.00
>
> b. Not 654321.000
>
> c. Not 7654321.00
>
> ?
>
> I am trying this code, but I am getting precision errors. Any ideas? Is my
> understanding of precision and scale incorrect? I want a number that can be
> 6 digits and 2 decimal places. What am I missing here? Thanks!
>
> --***********
>
> SET SERVEROUTPUT ON
> SET VERIFY OFF
> DECLARE
> v_number NUMBER(6,2) := &sv_number;
>
> BEGIN
> DBMS_OUTPUT.PUT_LINE(v_number);
>
> END;
> /
>
> --************
>
> Cheers,
> ~ck
You first number has 8 digits of precision and a scale of 2 so you need to declare it as (8,2) rather than (6,2). A format of (6,2) would support only digits to the left of the decimal point.
HTH -- Mark D Powell -- Received on Mon Nov 19 2007 - 12:04:07 CST
![]() |
![]() |