Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL variable argument list function
DanHW wrote:
>
> >Is it possible to create a function/procedure in PL/SQL with a
> >variable number of arguments (as in C)?
> >
> >Nuno Guerreiro
> Yes - there are two ways, depending on exactly what you are trying to do.
Emmm, not trying to be controversial, but I'd say "No" rather than "Yes"
to
the gist of the original question.
There's a bit of confusion here, and Dan's solution is a good one, but
it's not
general enough in my humble opinion (I'm guessing that Dan doesn't know
what
varargs (or "stdargs") in C are: hope I haven't guessed wrong).
A vararg function in C is one that can accept ONE or more arguments OF
ANY TYPE.
Dan's reply is to do with functions with default arguments (a lazy way
where
PL/SQL will supply default values if the user omits them - the function
or
procedure will always be given N arguments (assuming it's defined as
taking N
arguments) of the appropriate types its just that the user can omit
specifying
them but they will be supplied by PL/SQL instead).
Dan's second method is to overload a function with several guises, but
the
disadvantage here is that you have to specify each overloaded function
with
respect to it's quantity of arguments.
The overall problem (as I see it) is to write a procedure or function in
PL/SQL
which will take ANY NUMBER of parameters where each parameter can be of
ANY TYPE.
I haven't found such a facility in PL/SQL which will do that (this could
be my
ignorance of PL/SQL: please educate me if I'm wrong :-).
> Hope this wasn't too confusing...
>
> Dan Hekimian-Williams
Mungo Henning Received on Thu Jul 02 1998 - 05:53:43 CDT
![]() |
![]() |