Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to write a function with variable parameters?
create or replace function sf_case (case_1 element_type, case_2 element
type)
return var_name element_type;
is
begin
....
return(var_name);
end;
"Dino Hsu" <dino1_at_ms1.hinet.net> wrote in message
news:dpehht06m4vpvhj6nhihqdrna629aur9r2_at_4ax.com...
> Dear all,
>
> To similate the Oracle 8i CASE WHEN ... THEN ... ELSE ... END clause
> in Oracle 8, I need to write a stored function like this:
> FUNCTION sf_case(case1, case2, case3, ..., case-n, ...) RETURN NUMBER
> where case-n's are all of boolean type.
> This function will check case1 first, then case2, case3, etc., and
> return the n that first evaluates to true.
>
> An extended edition is like this:
> FUNCTION sf_case_ex(case1, value1, case2, value2, case3, value3, ...)
> RETURN value_type
> where value-n's are the corresponding return values.
>
> These two functions will compansate the limited DECODE() built-in
> function in Oracle 8. I cannot figure out how at the moment, I hope
> someone can help me with this. Thanks in advance.
>
> Dino
>
Received on Sat Jun 02 2001 - 11:56:12 CDT