Here's something for sybase:

=item $r->get_column_info ($tablename)

This method gets the name and type of all columns of the passed table name. It returns a reference to an array of array references of col name/value pairs.
Get results by typing $$res[0]->[0] or $$res[0]->[1] which return both values of the sql query for the first row


=cut

sub get_column_info {
        my $dbh                  = shift;
        my $tablename   = shift;

my $sql = "SELECT syscolumns.name, syscolumns.type FROM sysobjects, syscolumns WHERE sysobjects.id = syscolumns.id AND sysobjects.name = '".$tablename
."' ORDER BY syscolumns.name ASC";


my $aref = $dbh->selectall_arrayref($sql);

        foreach (@$aref) {
                $_->[1] = $SYBASE_TYPES_CONVERT{$_->[1]};
        }
        return $aref;
}



On Tuesday, June 10, 2003, at 02:40 PM, Igor Korolev wrote:

Right. Each database should have description tables for tables, indexes, etc.

In Oracle, you can use:

select column_name, data_type, nullable from all_tab_columns
where table_name = :1 order by column_id

-----Original Message-----
From: David N Murray [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 4:30 PM
To: Anthony Nickolayev
Cc: [EMAIL PROTECTED]
Subject: Re: How can I fetch column names?


Which database? It usually varies.


On Jun 10, Anthony Nickolayev scribed:

Greetings. Maybe the answer for my question will be RTFM, but i still cant find
it myself. The problem is: i need to fetch just list, contains column names - and
i dont know how to do it. I didnt find it in DBI manual page, and anywhere else.
Thanks anyway, and sorry for my english.





--- Henri Asseily [EMAIL PROTECTED] CTO & Founder, BizRate.com http://www.bizrate.com

"Que les inopérants laissent passer ceux qui font."
Greg




Reply via email to