Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

store the output in text file or xls file from plsql block

N_RajDec 13 2019 — edited Dec 13 2019

Hi All,

We have an oracle 11.2 on  Red-hat.

I am not plsql developer and trying to create a plsql procedure for our requirement.

We have table like emp_Temp,It has 100 rows,Just want to store those records in txt file or xls file  or xml file .For that,i just preparing as below.

It is working fine when the table has rows but i have 2 issues

1, When the table has zero rows, exception is not working. 

2, The output is not stored in the text file or excel file or xml file

set serveroutput on

spool Test.txt

or

set markup html on spool on

spool Test.xls

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

BEGIN

  FOR rec IN (SELECT name FROM emp_temp )

  LOOP

    DBMS_OUTPUT.PUT_LINE ('Employee Number: ' || rec.name);

  END LOOP;

  EXCEPTION

        WHEN NO_DATA_FOUND THEN

    dbms_output.put_line('Customer  does not exist');

END;

/

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Any Suggestions.

Thanks & Regards,

Comments
Post Details
Added on Dec 13 2019
3 comments
2,331 views