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

Java boundary seems to violate Oracle's constraints.

From: Galen Boyer <galenboyer_at_hotpop.com>
Date: 17 Jun 2004 18:24:18 -0500
Message-ID: <uwu25rcst.fsf@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

-- 
Galen Boyer
Received on Thu Jun 17 2004 - 18:24:18 CDT

Original text of this message

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