Function A(p_option number)
RETURN SYS_REFCURSOR
AS
CUR_1 SYS_REFCURSOR;
BEGIN
IF P_OPTION = 3 THEN
OPEN CUR_1 FOR
SELECT COL1, COL2, COL3, COL4, COL5,COL6,COL7
FROM
(SELECT
D.COL1,
A.COL2,
A.COL3,
trunc(A.COL4) COL4,
A.COL5,
(SELECT stc.COL6 FROM TABLE stc WHERE stc.COL1 = A.COL3) COL6,
A.COL7,
row_number() OVER (PARTITION BY A.COL2 ORDER BY A.COL10 DESC) NO
FROM
TABLE1 A ,TABLE2 C,TABLE3 D,TABLE4 E
WHERE A.COL11 = 'A'
AND A.COL2=D.COL1
AND A.COL3 = c.COL1
AND D.COL2=E.COL1)
WHERE NO <= 5;
ELSIF.......
END IF;
RETURN CUR_1;
END ;
FUNC OUTPUT:
COL1 || COL2 || COL3 || COL4 || COL5 || COL6 || COL7 安永|| ER || ET || EA || EF || EJ || ES
我想使用上面的函数创建一个视图。我不知道如何创建。请帮助我。
我的观点(VW_A)应如下所示:
CREATE VIEW VW_A
AS
SELECT T1.COL1,A(T2.OPTIONS) FROM TABLE1 T1,TABLE2 T2
WHERE T1.COL1=T2.COL1
AND T2.OPTIONS=3;
T1.COL1 || COL1 || COL2 || COL3 || COL4 || COL5 || COL6 || COL7
XXX ||安永|| ER || ET || EA || EF || EJ || ES