Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Number datatype help?

Re: Number datatype help?

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: Mon, 19 Nov 2007 10:04:07 -0800 (PST)
Message-ID: <9bdd1d64-c093-45ae-b048-c4f46739d47e@n20g2000hsh.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US