On Sat, Jun 02, 2001 at 06:59:42PM -0400, Ilya Zherebetskiy wrote:
> SQL Server 7/DBD::ODBC on BSD. I'm trying to retrieve a
> column name via perl dbi. I found this:
> SQLColumns -- $dbh->func(catalog, schema, table,
> column, 'columns') but I do not know how to use it.
>
> Any advice anyone?
The function call returns a statement handle. Using the statement
handle, you can call any of the "fetch" methods. Just a word of caution,
func() calls are normally NOT portable.
Here's a quick example I just worked up:
#!/usr/local/bin/perl -w
# vim:ts=4:sw=4:tw=78:
use strict;
use warnings;
use Carp;
use DBI;
my $dbh = DBI->connect() or croak $DBI::errstr;
$dbh->{RaiseError} = 1;
$dbh->{PrintError} = 1;
# Function returns a statement handle.
# Change UserID to your table name.
my $sth = $dbh->func(undef, undef, 'UserID', undef, 'columns');
{
no warnings;
local ($,) = q{,};
print @{$sth->{NAME}}, "\n";
# Use normal "fetch" methods.
while( my $row = $sth->fetchrow_arrayref ) {
print @$row, "\n";
}
}
$dbh->disconnect;
--
Thomas A. Lowery
See DBI/FAQ http://tlowery.hypermart.net
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com