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: PL/SQL bug ???

Re: PL/SQL bug ???

From: Izabella <Izabella.Urbanek_at_afp.gov.au>
Date: Thu, 22 Oct 1998 12:51:02 +1000
Message-ID: <70m6oq$a78$1@platinum.sge.net>


Why don't you try rewriting the function this way, it gives you the sum of values of A (assuming you don't want to do anything more complicated):

create or replace function Unitest (pndmg number) return number as

   ile number := 0;
begin

   select sum(a)
   into ile
   from tst ;

   return nvl(ile, 0);
end;
/

Jarek Palka wrote in message <70i4ab$i0n_at_router.kamsoft.com.pl>...
>I wrote a PL/SQL function, similar to this one :
>
>CREATE OR REPLACE FUNCTION Unitest (pndmg number)
>RETURN NUMBER IS
> ile NUMBER ;
>BEGIN
> select sum(a)
> into ile
> from(
> select a from tst
> union all
> select 0 from dual
> );
>
> RETURN ile;
>END;
>
>
>Table TST is declared : TABLE TST (A NUMBER(5)); Table is empty.
>In my opinion function should return sum of values of column A from table
>TST, but if I issue statement :
>
>SELECT unitest(1111) from dual;
>------
>1111
>
>SELECT unitest(100) from dual;
>------
>100
>
>After inserting a row to TST :
>
>SELECT unitest(1111) from dual;
>------
>2222
>
>It means that function returns value of input parameter multiplied by
number
>of rows in SELECT statement in function body !!!!!!??????
>
>I tested this function on Oracle 8 EE for NT, Personal Oracle 8 for W'95
and
>Oracle 8 for Linux.
>Results are the same.
>On Oracle 7.3 for NT this function cannot be compiled.
>
>Is it serious PL/SQL bug ???
>
>
>Jarek Palka,
>P.I. Kamsoft
>Katowice, POLAND
>
>
Received on Wed Oct 21 1998 - 21:51:02 CDT

Original text of this message

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