日期:2014-05-16 浏览次数:20567 次
CREATE OR REPLACE FUNCTION FUN_GETNAME ( ID IN NUMBER ) RETURN VARCHAR2 IS RESULT_OUT VARCHAR2(20000); BEGIN DECLARE CURSOR C_CUR IS SELECT CTASKID FROM TABLE_B WHERE CID = ID ORDER BY CTASKID; BEGIN FOR ROWSTR IN C_CUR LOOP RESULT_OUT := RESULT_OUT || ',' || ROWSTR.CTASKID; END LOOP; END; RESULT_OUT := SUBSTR(RESULT_OUT, 2); RETURN RESULT_OUT; END; /
SELECT A.ID, A.NAME, A.FLAG, A.DELETE_FLAG, FUN_GETNAME(A.CODE) AS SCH FROM TABLE_A A ORDER BY A.ID, SCH