17,377
社区成员
发帖
与我相关
我的任务
分享
create or replace function math(p_type varchar2,
p_param1 number,
p_param2 number) return number is
v_result number;
begin
if p_type = '+' then
v_result := p_param1 + p_param2;
elsif p_type = '-' then
v_result := p_param1 - p_param2;
elsif p_type = '*' then
v_result := p_param1 * p_param2;
else
v_result := p_param1 / p_param2;
end if;
return v_result;
exception
when others then
dbms_output.put_line(sqlerrm);
return null;
end math;
--Day of week (1-7). 1星期天,2星期一,3星期二...7星期六
select to_char(sysdate,'D') ts from dual;
--然后 case when那些你想怎么判断想怎么返回都可以了