17,377
社区成员
发帖
与我相关
我的任务
分享
select fun_name into v_t from sm_funcregister where fun_node = substr(v_input,1,v_i);
if v_i = 2 then
v_r := v_t;
else
v_r := v_r||'-'||v_t; /*这里岂不是重复了,比如说有个数据是2014,第一次循环的话v_r和v_t都为20,第二次循环的时候v_i变为4,那么在substr函数中就会提取出2014给v_t,那么这个时候v_r就会被赋值为20||2014=202014*/
end if;
v_i := v_i + 2;
create or replace procedure proc(v_input in varchar2)
is
v_i number := 2;
v_t varchar2(200);
v_r varchar2(2000);
begin
if length(v_input) < 2 then
v_r := ' ';
dbms_output.put_line('invalid input value');
else
while v_i <= length(v_input) loop
select fun_name into v_t from sm_funcregister where fun_node = substr(v_input,1,v_i);
if v_i = 2 then
v_r := v_t;
else
v_r := v_r||'-'||v_t;
end if;
v_i := v_i + 2;
end loop;
end if;
dbms_output.put_line(v_r);
exception
when no_data_found then
v_r := ' ';
dbms_output.put_line('no record found');
when others then
raise;
end proc;
create or replace procedure proc(v_input in varchar2,v_r out varchar2)
is
v_i number := 2;
v_t varchar2(200);
begin
if length(v_input) < 2 then
v_r := ' ';
dbms_output.put_line('invalid input value');
else
while v_i <= length(v_input) loop
select fun_name into v_t from sm_funcregister where fun_node = substr(v_input,1,v_i);
if v_i = 2 then
v_r := v_t;
else
v_r := v_r||'-'||v_t;
end if;
v_i := v_i + 2;
end loop;
end if;
exception
when no_data_found then
v_r := ' ';
dbms_output.put_line('no record found');
when others then
raise;
end proc;