Loading ...
Sorry, an error occurred while loading the content.
 

column headers in sql query in perl script

Expand Messages
  • Ankur
    Hi, I am having a perl script which outputs the table data from sybase db in the output.csv file using sql query ... But I need to have column headers/col
    Message 1 of 2 , Oct 10 8:34 AM
      Hi,

      I am having a perl script which outputs the table data from sybase db
      in the output.csv file using sql query ...

      But I need to have column headers/col name as well in the output data
      which is not there at present

      iam running the perl script through unix

      & when i view the content of o/p file on unix or sql on unix it has
      all the required data but without col headers ..

      Is there any way in which col names can be added in teh 1st row of
      result set ...?

      please suggest !
      many thanks,
      Ankur
    • merlyn@stonehenge.com
      ... Ankur I am having a perl script which outputs the table data from sybase db Ankur in the output.csv file using sql query ... Are you using DBI? If so,
      Message 2 of 2 , Oct 10 8:51 AM
        >>>>> "Ankur" == Ankur <ankurzvohra@...> writes:

        Ankur> I am having a perl script which outputs the table data from sybase db
        Ankur> in the output.csv file using sql query ...

        Are you using DBI?

        If so, you can call $sth->{NAME} to get an arrayref of the names of your
        columns after the query has been executed. There's an example on
        the DBI manpage:

        print "First column name: $sth->{NAME}->[0]\n";

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
        See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
      Your message has been successfully submitted and would be delivered to recipients shortly.