Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Declaring a function ...
On Thu, 29 Jul 1999 18:52:13 +0200, Anonymous <nobody_at_newsfeeds.com> wrote:
>
>I would like to create a function without knowing the number of arguments
>like GREATEST(a1, a2, ...).
>
>Does anyone know the syntax ?
>An example please !!! :-)
You can't do it directly, but you can use a user defined type in Oracle 8 to achieve the same result.
eg.
SQL> create or replace
2 type argv as
3 table of number;
4 /
Type created.
SQL> l
1 create or replace
2 function my_greatest( p_list argv ) return number as
3 l_greatest number;
4 begin
5 l_greatest := p_list(1);
6 for i in 2 .. p_list.count loop
7 if p_list(i) > l_greatest then 8 l_greatest := p_list(i); 9 end if;
SQL> begin
2 dbms_output.put_line( my_greatest( argv( 1,2,3,4,5 ) ) );
3 end;
4 /
5
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_output.put_line( my_greatest( argv( 1,2,3,4,5,6,7,8,9,10) ) );
3 end;
4 /
10
PL/SQL procedure successfully completed.
hope this helps.
chris.
>
>Thank !!!
>
>
>San_at_a2c.fr
>
>
>
> --------== Posted Anonymously via Newsfeeds.Com ==-------
> Featuring the worlds only Anonymous Usenet Server
> -----------== http://www.newsfeeds.com ==----------
--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.