create function get_value(p_id)
return varchar2
as
cursor t_sor is
select grade from table1 where id=p_id;
str varchar2(50);
begin
for v_sor in t_sor loop
str:=str||v_sor.grade;
end loop;
return str;
end;
/select id,name,get_value(id) from table1 group by id,name;

解决方案 »

  1.   

    beckhambobo(beckham)的方法不错.
      

  2.   

    create or replace function get_value(p_id in int)
    return varchar2
    is
    cursor t_sor is select grade from table1 where id=p_id;
    str varchar2(200);
    begin
    for v_sor in t_sor loop
      str:=str||v_sor.grade;
    end loop;
    return str;
    end;
    /select id,name,get_value(id) from table1 group by id,name;
      

  3.   

    create function get_value(p_id)
    return varchar2
    as
    cursor t_sor is
    select grade from table1 where id=p_id;
    str varchar2(50);
    begin
    for v_sor in t_sor loop
    str:=str||v_sor.grade;
    end loop;
    return str;
    end;
    /select id,name,get_value(id) from table1 group by id,name;推荐  beckhambobo(beckham) 的方法
      

  4.   

    楼上
    create function get_value(p_id)
    p_id 后面可以不加类型吗?
      

  5.   

    sorry,看漏眼了
    create function get_value(p_id in varchar2)