Hi,

The following script:

use DBI;
DBI->trace(3, "trace.log");
my $dbh = DBI->connect('DBI:ODBC:testdb', 'sa', '');
my $sth = $dbh->prepare("create table foo (a int)");
$sth->execute;
$sth = $dbh->prepare("alter table foo add b int");
$sth->execute;
my $names = $sth->{NAME};
$sth->finish;
$dbh->disconnect;

errors out with:

Describe failed during DBI::st=HASH(0x1c84838)->FETCH(NAME) at test_alter.pl line 10.

In the trace.log, the error from ODBC is:

[Microsoft][ODBC SQL Server Driver][SQL Server]Column names in each table must be 
unique. Column name 'b' in table 'foo' is specified more than once. (SQL-42S21)(DBD: 
dbd_describe/SQLNumResultCols err=-1)

If I remove the call to $sth->{NAME}, everything works. This seems to
imply that accessing NAME is executing the query again for some reason
(in the above example of course there is no reason to call NAME, but
this is a snippet from a larger module). This is with perl 5.6.1
(build 633), DBI 1.34 and DBD::ODBC 1.04.

Any ideas on workarounds? 

Cheers,

Alex

Reply via email to