Re: How to write user-defined aggregate function

From: Daniel Roy <danielroy10_at_hotmail.com>
Date: 15 Nov 2002 07:12:11 -0800
Message-ID: <1b061893.0211150712.27301e76_at_posting.google.com>


If I understand well your question, you want to call this function for every employee in the emp table. There are probably 10 ways to do that. I would use an anonymous block which calls this function:

declare

     cursor my_employees_cur is
          select * from emp;
     rc number(?,?);
begin
     for my_employees in my_employees_cur
     loop
          rc = my_function (my_employees.sal);
          dbms_output.put_line(my_employees.name || ' ' ||
my_employees.sal || ' ' || rc);
     end loop;

end;

This is untested, and without anything fancy (exception handling, ...)! Hope this is what you're looking for.

Daniel

> > How to make a loop to get the values from sal? Where can I find a complete > > example?
 

> > create function my_function (sal in number)
> > return number is
> > "VARIABLE DECLARATION"
> > BEGIN
> > ....
> > return return_value;
> > end my_function;
> >
> >
> > > How to write an user-defined aggregate function? e.g. select
> > > my_function(sal) from emp;
Received on Fri Nov 15 2002 - 16:12:11 CET

Original text of this message