----------利用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;