Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: varargs in PL/SQL

Re: varargs in PL/SQL

From: tony_becky_mikey_verizon_news <Xyz_at_pdq.com>
Date: Sat, 24 Feb 2007 18:26:39 -0600
Message-ID: <45e0d815$0$28139$4c368faf@roadrunner.com>


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.
>



I am using the free version of SPAMfighter for private users. It has removed 104 spam emails to date.
Paying users do not have this message in their emails. Try SPAMfighter for free now! Received on Sat Feb 24 2007 - 18:26:39 CST

Original text of this message

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