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

Thanks a lot! One more question, how do I add the title(i.e. Column name) to each column in the csv file?
  • Comment on Re: Re: save the result of sql query in csv file

Replies are listed 'Best First'.
Re: Re: Re: save the result of sql query in csv file
by astroboy (Chaplain) on Mar 24, 2004 at 12:07 UTC
    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