----------利用function 取得版主信息 function getowneroftheme(p_themeid number) return varchar2 is tempstr varchar2(300); tempcur tcur; vuserid varchar2(20); vusername varchar2(20); begin open tempcur for select a.userid,a.username from home_user a,home_forumowner b where a.userid=b.userid and b.themeid=p_themeid; loop fetch tempcur into vuserid,vusername; exit when tempcur%notfound or tempcur%notfound is null; tempstr:=tempstr || vuserid ||':'||vusername||','; end loop; close tempcur; return tempstr; end;
---在调用的存储过程中,在select子句中调用function的值 procedure() is begin select themeid,getowneroftheme(themeid) owner from home_forumtheme order by themeid; end;