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: Java boundary seems to violate Oracle's constraints.

Re: Java boundary seems to violate Oracle's constraints.

From: Karsten Schmidt <groups_at_karsten-schmidt.com>
Date: 18 Jun 2004 05:06:16 -0700
Message-ID: <c6711ac4.0406180406.5be6058f@posting.google.com>


Hi,
 don't think this violates any constraints and such.  I did not check the actual bits you put in there, but it looks like you are hitting one of the 'magic' values that an Ieee float can take.  in your case, looks like negative infinity.

 Perfectly valid number, mathematically speaking, just that you can not do any sensible computations with it.

 check out the ieee standard:
http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html

Karsten

Galen Boyer <galenboyer_at_hotpop.com> wrote in message news:<uwu25rcst.fsf_at_standardandpoors.com>...
> I'm going to post some compilable code and steps for you to run
> and then I'll finish with the results. Tell me if you get the
> same result and is it puzzling or not.
>
> Oracle 9.2.0.4.0,
>
> /* HERE IS THE CODE */
>
> create or replace and resolve java source named "Converter" as
>
> public final class Converter
> {
> public static final double a_double( String elementValue ) throws Exception
> {
> if (elementValue == null)
> return Double.longBitsToDouble(Long.parseLong("0"));
> else if (Double.isNaN(Double.longBitsToDouble(Long.parseLong(elementValue))))
> return 0;
> else
> return Double.longBitsToDouble(Long.parseLong(elementValue));
> }
>
> }
> /
>
> CREATE OR REPLACE FUNCTION gbits (a_element IN varchar2) return number
> as language java name 'Converter.a_double(java.lang.String) return number';
> /
>
> CREATE OR REPLACE PACKAGE converter
> AS
> function bits (a_element IN varchar2) return number;
> END converter;
> /
>
> CREATE OR REPLACE PACKAGE BODY converter
> AS
>
> FUNCTION bits (a_element in varchar2) return number
> AS
> BEGIN
> return gbits(a_element);
> END bits;
>
> END converter;
> /
>
> /* HERE IS THE TABLE AND INSERT */
>
> create table t1 (fld number);
>
> insert into t1 select converter.bits(-4503599627370496) from dual;
>
> /* NOW HERE IS THE RESULT */
>
> select * from t1;
>
> FLD
> ----------
> -~
>
> Anybody know what this is? Looks like the java engine talked to
> the C/C++ engine and they decided to let this through.
>
> Can't do any normal operations with it...
>
> SQL> select fld - 1000 from t1;
> select fld - 1000 from t1
> *
> ERROR at line 1:
> ORA-01426: numeric overflow
>
>
> SQL> select fld+ 1000 from t1;
> select fld+ 1000 from t1
> *
> ERROR at line 1:
> ORA-01426: numeric overflow
>
>
> SQL> select fld - fld from t1;
> select fld - fld from t1
> *
> ERROR at line 1:
> ORA-01426: numeric overflow
Received on Fri Jun 18 2004 - 07:06:16 CDT

Original text of this message

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