Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Number datatype help?
<fitzjarrell_at_cox.net> schreef in bericht news:667bc55a-f58c-4b53-b1a1-5824d40c7f13_at_f13g2000hsa.googlegroups.com...
> On Nov 19, 12:31 pm, "CK" <c_kettenb..._at_hotmail.com> wrote:>> > need to declare it as (8,2) rather than (6,2). A format of (6,2)
>> > You first number has 8 digits of precision and a scale of 2 so you
> > Code an exception: > > DECLARE > v_number NUMBER(8,2) := &&sv_number; > too_many_decimals exception; > > pragma exception_init(too_many_decimals, -20001); > BEGIN > if length(substr(&&sv_number,instr(&&sv_number,'.')+1)) = 3 then > raise too_many_decimals; > else > DBMS_OUTPUT.PUT_LINE(v_number); > end if; > EXCEPTION > when value_error then > raise_application_error(-6502, 'Number too large'); > when too_many_decimals then > raise_application_error(-20001, 'Too many decimal > places'); > when others then > raise_application_error(SQLCODE, SQLERRM); > > END; > / > > This is not intended to be an exhaustive example, merely a starting > point to get you going. > > > David Fitzjarrell
And take care of language settings... this will fail when the decimal seperator becomes a ','.
Shakespeare Received on Wed Nov 21 2007 - 05:08:53 CST
![]() |
![]() |