Re: varargs in PL/SQL
- From: yf110@xxxxxxxxxxxxxxxxxxx (Malcolm Dew-Jones)
- Date: 24 Feb 2007 13:38:41 -0700
Filipe David Borba Manana (fdmanana@xxxxxxx) 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.
.
- Follow-Ups:
- Re: varargs in PL/SQL
- From: tony_becky_mikey_verizon_news
- Re: varargs in PL/SQL
- References:
- varargs in PL/SQL
- From: Filipe David Borba Manana
- varargs in PL/SQL
- Prev by Date: Re: Aide en Francais ?
- Next by Date: Re: varargs in PL/SQL
- Previous by thread: Re: varargs in PL/SQL
- Next by thread: Re: varargs in PL/SQL
- Index(es):