一个函数,不知道错在哪里了?
无爱大叔 2011-08-02 01:37:39 create or replace function Get_DZString(fhpzbm in varchar2) return varchar2 is
Result varchar2(200);
begin
declare
/* 根据传入的编码得到到站字符串,如:到站1;到站2; */
--定义游标
cursor cur_dz(vfhpzbm varchar2) is
select dz from fh_fhpz where fhpzbm in (vfhpzbm) and scbr='N';
--执行游标
begin
for obj in cur_dz(fhpzbm) loop
if obj.dz is not null then
Result:=Result||obj.dz||';';
end if;
end loop;
end;
return(Result);
end Get_DZString;
函数编译通过,执行
-- Created on 2011-8-2 by ADMINISTRATOR
declare
-- Local variables here
ss varchar2(200);
begin
-- Test statements here
select get_dzstring('211000000131,221000000421') into ss from dual;
dbms_output.put_line(ss);
end;
输出内容为空,正确的输出应该是:贵州;重庆;
select get_dzstring('21100000013') into ss from dual;
传入的字符串为单个的,输出正常,结果为:贵州;
help me