in reply to Re: Re: save the result of sql query in csv file
in thread save the result of sql query in csv file

Well, there are a number of ways. You could just print it prior to your loop:
print FH "deptno, dname, loc\n";

But you could also derive the column names at run time from your statement handle (using $sth->{NAME}). Unless you don't know your column names in advance, I'd go for the simple print option