1 CREATE OR REPLACE FUNCTION F_AA(P_D in date, P_A in number) return varchar2 is 2 Result varchar2(200); 3 ls_name varchar2(20); 4 5 CURSOR myCur1 IS 6 SELECT Ts_Flag, C_NAME FROM tableA 7 where p_DATE = P_D and Pt_A = P_A ; 8 BEGIN 9 Result := ''; 10 ls_name := ''; 11 12 FOR lp1 IN myCur1 LOOP 13 CASE lp1.Ts_Flag 14 WHEN 'X' THEN ls_name := 'A'||lp1.C_NAME; 15 WHEN 'Y' THEN ls_name := '*'||lp1.C_NAME; 16 ELSE ls_name := lp1.C_NAME; 17 END CASE; 18 19 IF Result is null THEN 20 Result := ls_name ; 21 ELSE 22 Result := Result||'~'||ls_name ; 23 END IF; 24 25 END LOOP; 26 27 return(Result); 28 END ;