create or replace function f_get_prodname(chan_pin_lx in varchar2,chan_pin_mc in varchar2) return varchar2 is
Result varchar2(100);
begin
if chan_pin_lx='项目销售' then
select t.xiang_mu_mc
into result
from ueoa_xmgl_lxspb t
where t.xiang_mu_bh=chan_pin_mc;
return(Result);
else
select t.chan_pin_mc
into result
from ueoa_khfw_gscpdj t
where t.chan_pin_bh=chan_pin_mc;
return(Result);
end if ;
end f_get_prodname;
反正我再pl/sql上面编译没有错,但是,就是不出来值,郁闷啊!能不能帮咱一下.谢谢了
Result varchar2(100);
begin
if chan_pin_lx='项目销售' then
select t.xiang_mu_mc
into result
from ueoa_xmgl_lxspb t
where t.xiang_mu_bh=chan_pin_mc;
return(Result);
else
select t.chan_pin_mc
into result
from ueoa_khfw_gscpdj t
where t.chan_pin_bh=chan_pin_mc;
return(Result);
end if ;
end f_get_prodname;
反正我再pl/sql上面编译没有错,但是,就是不出来值,郁闷啊!能不能帮咱一下.谢谢了
我在机器上做了测试,正常情况下没有问题,函数返回值正常。返回多行会报错,没有返回值就什么也出不来了
WHEN NO_DATA_FOUND
和WHEN TOO_MANY_ROWS!
chan_pin_lx in varchar2,chan_pin_mc in varchar2
)
return varchar2
as
begin
RETURN case when chan_pin_lx='项目销售' then (select t.xiang_mu_mc
from ueoa_xmgl_lxspb t where t.xiang_mu_bh=chan_pin_mc)
else (select t.chan_pin_mc from ueoa_khfw_gscpdj t
where t.chan_pin_bh=chan_pin_mc)
end;
end ;
如果为NULL或为多条时都有可能没有返回值。