I have a question to consult experts.
I need to spool the data by dept no to excel file and the file name will be with dept no.
For example, I have 10 depts. I would like to spool the data to 10 excel files. The script should include a cursor. I do not know how to do it.
Here is my sql script but it does not work:
Declare
cursor c1 is
select dept_no from dept;
begin
for r1 in c1 loop
spool c:\dept&r1.dept_no.xls;
select emp_id, first_name, last_name
from emp
where dept_no = r1.dept_no;
spool off;
end loop;
end;
Thanks a lot for any help.
I need to spool the data by dept no to excel file and the file name will be with dept no.
For example, I have 10 depts. I would like to spool the data to 10 excel files. The script should include a cursor. I do not know how to do it.
Here is my sql script but it does not work:
Declare
cursor c1 is
select dept_no from dept;
begin
for r1 in c1 loop
spool c:\dept&r1.dept_no.xls;
select emp_id, first_name, last_name
from emp
where dept_no = r1.dept_no;
spool off;
end loop;
end;
Thanks a lot for any help.