Código SQL:
Pero cuando la voy a ejecutar Ver original
CREATE OR REPLACE TYPE T_Record IS OBJECT ( Account_ID NUMERIC, DATEACCT TIMESTAMP, AMTSourceDR NUMERIC, AMTSourceCR NUMERIC, AMTSourceN NUMERIC ); CREATE OR REPLACE TYPE T_RecordNode IS OBJECT ( nodeid NUMERIC ); CREATE OR REPLACE TYPE T_RecordEV IS OBJECT ( elementvalue NUMERIC, reportline NUMERIC ); -- Creado el Tipo de Objeto DROP TYPE T_TableRecordNode CREATE OR REPLACE TYPE T_TableRecord AS TABLE OF T_Record; CREATE OR REPLACE TYPE T_TableRecordEV AS TABLE OF T_RecordEV; CREATE OR REPLACE TYPE T_TableRecordNode AS TABLE OF T_RecordNode; -- Creado el Tipo de Tabla CREATE OR REPLACE FUNCTION FN_TableRecord(valor1 IN NUMERIC, valor2 IN NUMERIC) RETURN T_TableRecord AS rs T_TableRecord; recor T_TableRecordNode; rsl T_TableRecordEV; sumary CHAR(1); BEGIN RAISE 'entro'; IF $1 IS NULL THEN FOR SELECT rsl IN SELECT rsu.c_elementvalue_id, rsu.pa_reportline_id FROM c_elementvalue ev INNER JOIN pa_reportsource rsu ON ev.c_elementvalue_id = rsu.c_elementvalue_id WHERE ev.ad_client_id = $2 LOOP FOR rs IN SELECT rsl.pa_reportline_id, rsl.c_elementvalue_id,DATEACCT, AmtSourceDR, AmtSourceCR, AmtSourceN FROM TABLE(FN_TableRecord(rsl.c_elementvalue_id,$2)) LOOP RETURN rs; END LOOP; END LOOP; ELSE sumary := (SELECT issummary FROM c_elementvalue WHERE c_elementvalue_id = $1); IF sumary = 'Y' THEN FOR recor IN SELECT node_id FROM ad_treenode tn INNER JOIN ad_tree t ON tn.ad_tree_id = t.ad_tree_id WHERE parent_id = $1 AND t.treetype = 'EV' LOOP FOR rs IN SELECT * FROM TABLE(FN_TableRecord(recor.node_id,$2)) LOOP RETURN rs; END LOOP; END LOOP; ELSE FOR rs IN SELECT Account_ID, DATEACCT, SUM(AmtSourceDR) AS AmtSourceDR,SUM(AmtSourceCR) AS AmtSourceCR,SUM(AmtSourceDR-AmtSourceCR) AS AmtSourceN FROM FACT_ACCT WHERE Account_ID = $1 GROUP BY Account_ID,DATEACCT LOOP RETURN rs; END LOOP; END IF; END IF; END; LANGUAGE 'PL/SQL';
Código SQL:
Me genera este error: Ver original
SELECT * FROM TABLE(FN_TableRecord(NULL,1000000))
ORA-06575: La función o el paquete FN_TABLERECORD tienen en un estado no válido
Línea de script 69, línea de instrucción 1, columna 20
Espero me puedan ayudar, Gracias.