Code :
CREATE OR REPLACE TYPE GEDTE_ROW AS OBJECT ( CODSOC INTEGER, LIB1 VARCHAR2(30 CHAR), LIB2 VARCHAR2(30 CHAR), LIB3 VARCHAR2(30 CHAR), LIB4 VARCHAR2(30 CHAR), LIB5 VARCHAR2(30 CHAR), LIB6 VARCHAR2(30 CHAR), LIB7 VARCHAR2(30 CHAR), LIB8 VARCHAR2(30 CHAR), LIB9 VARCHAR2(30 CHAR), LIB10 VARCHAR2(30 CHAR), LIB11 VARCHAR2(30 CHAR), LIB12 VARCHAR2(30 CHAR), LIB13 VARCHAR2(30 CHAR), LIB14 VARCHAR2(30 CHAR), LIB15 VARCHAR2(30 CHAR), LIB16 VARCHAR2(30 CHAR), LIB17 VARCHAR2(30 CHAR), LIB18 VARCHAR2(30 CHAR), LIB19 VARCHAR2(30 CHAR), LIB20 VARCHAR2(30 CHAR), DAT1 VARCHAR2(8 CHAR), DAT2 VARCHAR2(8 CHAR), DAT3 VARCHAR2(8 CHAR), DAT4 VARCHAR2(8 CHAR), DAT5 VARCHAR2(8 CHAR), NUM01 INTEGER, NUM02 INTEGER, NUM03 INTEGER, NUM04 INTEGER, NUM05 INTEGER, NUM06 INTEGER, NUM07 INTEGER, NUM08 INTEGER, NUM09 INTEGER, NUM10 INTEGER, VAL01 NUMBER, VAL02 NUMBER, VAL03 NUMBER, VAL04 NUMBER, VAL05 NUMBER, VAL06 NUMBER, VAL07 NUMBER, VAL08 NUMBER, VAL09 NUMBER, VAL10 NUMBER, VAL11 NUMBER, VAL12 NUMBER, VAL13 NUMBER, VAL14 NUMBER, VAL15 NUMBER, VAL16 NUMBER, VAL17 NUMBER, VAL18 NUMBER, VAL19 NUMBER, VAL20 NUMBER ); CREATE OR REPLACE TYPE GEDTE_TABLE AS TABLE OF GEDTE_ROW; CREATE OR REPLACE FUNCTION get_vue (p_vue IN VARCHAR2, p_codsoc IN INTEGER) RETURN gedte_table PIPELINED IS v_requete VARCHAR2 (500); c1 sys_refcursor; out_rec gedte_row; BEGIN -- Initialisation de l'objet out_rec ( Object Type Constructor Method ) out_rec := gedte_row (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); -- Ouverture du curseur SQL Dynamique OPEN c1 FOR 'select * from ' || p_vue || ' where codsoc=' || p_codsoc; LOOP FETCH c1 INTO out_rec.codsoc, out_rec.lib1, out_rec.lib2, out_rec.lib3, out_rec.lib4, out_rec.lib5, out_rec.lib6, out_rec.lib7, out_rec.lib8, out_rec.lib9, out_rec.lib10, out_rec.lib11, out_rec.lib12, out_rec.lib13, out_rec.lib14, out_rec.lib15, out_rec.lib16, out_rec.lib17, out_rec.lib18, out_rec.lib19, out_rec.lib20, out_rec.dat1, out_rec.dat2, out_rec.dat3, out_rec.dat4, out_rec.dat5, out_rec.num01, out_rec.num02, out_rec.num03, out_rec.num04, out_rec.num05, out_rec.num06, out_rec.num07, out_rec.num08, out_rec.num09, out_rec.num10, out_rec.val01, out_rec.val02, out_rec.val03, out_rec.val04, out_rec.val05, out_rec.val06, out_rec.val07, out_rec.val08, out_rec.val09, out_rec.val10, out_rec.val11, out_rec.val12, out_rec.val13, out_rec.val14, out_rec.val15, out_rec.val16, out_rec.val17, out_rec.val18, out_rec.val19, out_rec.val20; EXIT WHEN c1%NOTFOUND; PIPE ROW (out_rec); END LOOP; CLOSE c1; RETURN; END get_vue; /
|