using cursor and table type
DECLARE
OUTPUTRESULT CLOB;
type output_result is table of varchar2(2000);
output_var output_result := output_result();
CURSOR QUERRYCUR IS
--- some query select * from employee
L_SOGG_ID NUMBER;
INTESTAZIONE VARCHAR2(200);
TEMPOUTPUT VARCHAR2(400);
BEGIN
OUTPUTRESULT := '';
TEMPOUTPUT := '';
FOR LTEMPCUR IN QUERRYCUR
LOOP
L_SOGG_ID := some value retirved from the function
INTESTAZIONE := N_PKG_XXXX.AN_FN_XXXXX(TO_CHAR(L_SOGG_ID));
TEMPOUTPUT := LTEMPCUR.CIFRE_13 ';' INTESTAZIONE ';' LTEMPCUR.SUCCURSALE ';' '\N' ;
output_var.extend;
output_var(output_var.last):=TEMPOUTPUT;
OUTPUTRESULT := OUTPUTRESULT TEMPOUTPUT;
DBMS_OUTPUT.PUT_LINE('OUTPUTRESULT :' TEMPOUTPUT);
END LOOP;
DBMS_OUTPUT.PUT_LINE('OUTPUTRESULT :' SUBSTR (TO_CHAR (OUTPUTRESULT),1,200) );
for i in output_var.first..output_var.last
loop
DBMS_OUTPUT.PUT_LINE(output_var(i));
END LOOP;
EXCEPTION
WHEN OTHERS THEN
OUTPUTRESULT := SQLERRM(SQLCODE);
DBMS_OUTPUT.PUT_LINE('OUTPUTRESULT :' SUBSTR(TO_CHAR(OUTPUTRESULT),1,200) );
END;
No comments:
Post a Comment