Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: varargs in PL/SQL
You can also use polymorphic procedures.. They have the same name, but
different interface definitions..
Oracle, when you call the procedure will figure out which one to use, based
upon the parameters you pass in..
"Malcolm Dew-Jones" <yf110_at_vtn1.victoria.tc.ca> wrote in message
news:45e0b061$1_at_news.victoria.tc.ca...
> Filipe David Borba Manana (fdmanana_at_cern.ch) wrote:
> : Is there any way to create a function/procedure in PL/SQL with a
> : variable arguments lists?
>
> : I want to create a procedure which may be called with 1, 2, 3... or any
> : number of parameters, say, something like the printf family of functions
> : in C.
>
> : Anyway to do it?
>
> No, but...
>
> you can define a procedure that takes a large number of parameters and
> defaults them all to NULL.
>
> create procedure print_lines (
> p1 varchar2 default := NULL ,
> p2 varchar2 default := NULL ,
> ...
> p99 varchar2 default := NULL )
> ...
> begin
> if p1 is not null then dbms_output.print_line(p1); end if;
> if p2 is not null then dbms_output.print_line(p2); end if;
> ...
> if p99 is not null then dbms_output.print_line(p99); end if;
> end
>
>
> which can then be called like
> print_lines(
> 'This is the first line',
> ' ',
> 'This is actuially the third line.'
> 'The end.' );
>
> it isn't elegent but it works.
>
> OR
>
> put the varying parameters in an array and pass the array as the
> parameter.
>
![]() |
![]() |