> 
> I recently upgrading a Win32/Activestate system to 
> ActiveState build 806 with DBD::ODBC 1.05 and DBI 1.37.  I 
> find that I now get errors of the following type when I try 
> to create a view over DBD::Proxy from my Linux box.
> 
> DBD::Proxy::db do failed: Server returned error: Failed to 
> execute method CallMethod: Describe failed during 
> DBI::ProxyServer::st=HASH(0x1f00888)->FETCH(NUM_OF_FIELDS)
> at R:/Perl/site/lib/DBI/ProxyServer.pm line 287.
> 
> 
> It would appear that NUM_OF_FIELDS fetched after the 
> execute() for a CREATE VIEW statement crashes out. I am able 
> to reproduce this with a simple script running on the Win32 box...
> 
> use strict;
> use warnings;
> use DBI;
> DBI->trace(11);
> my $db = DBI->connect;
> $db->{RaiseError} = 1;
> my $sth = $db->prepare('CREATE VIEW WIBBLE AS SELECT 1 AS 
> WUBBLE'); $sth->execute(); print $sth->{NUM_OF_FIELDS};
> 
> __END__
> 
> Looking at the relevant part of the trace output...
> 
>     >> FETCH       DISPATCH (DBI::st=HASH(0x1bd9138) rc2/1 @2 
> g0 ima404 pid#1412) at L:\home\bam\tmp\foo.pl line 10
>     -> FETCH for DBD::ODBC::st (DBI::st=HASH(0x1bd9138)~INNER 
> 'NUM_OF_FIELDS') thr#15d44d4 Describe failed during 
> DBI::st=HASH(0x1bd9138)->FETCH(NUM_OF_FIELDS) at 
> L:\home\bam\tmp\foo.pl line 10.
>     >> DESTROY     DISPATCH (DBI::st=HASH(0x1bd918c) rc1/1 @1 
> g0 ima4 pid#1412)
>     <> DESTROY ignored for outer handle 
> DBI::st=HASH(0x1bd918c) (inner DBI::st=HASH(0x1bd9138))
>     >> DESTROY     DISPATCH (DBI::db=HASH(0x1bd7278) rc1/1 @1 
> g0 ima4 pid#1412)
>     <> DESTROY ignored for outer handle 
> DBI::db=HASH(0x1bd7278) (inner DBI::db=HASH(0x1bd9108))
>     >> DESTROY     DISPATCH (DBI::st=HASH(0x1bd9138) rc1/1 @1 
> g0 ima4 pid#1412)
>     -> DESTROY for DBD::ODBC::st 
> (DBI::st=HASH(0x1bd9138)~INNER) thr#15d44d4
>        error: -1 '[Microsoft][ODBC SQL Server Driver][SQL 
> Server]'CREATE VIEW' must be the first statement in a query 
> batch. (SQL-42000)(DBD: dbd_describe/SQLNumResultCols err=-1)'
>     <- DESTROY= undef
> 
> So it would appear that the mechanism used to calculate 
> NUM_OF_FIELDS in DBD::ODBC is flawed.  
> 
> Actually, it looks like this could be a problem with the 
> inplementation of SQLNumResultCols is the ODBC driver for 
> MSSQL rather than DBD::ODBC.  
> 
> Looking at the MSSQL profiler trace I see that the ODBC 
> driver appears to be doing..
>   SET FMTONLY ON CREATE VIEW WIBBLE AS SELECT 1 AS WUBBLE SET 
> FMTONLY OFF
> 
> Sure enough, if I try to issue this command via the MSSQL 
> query analyser I get the error..
>    'CREATE VIEW' must be the first statement in a query batch.
> 
> I first observed this versions 2000.80.528.00 and 
> 2000.80.194.00 of the driver.
> 
> I've now downloaded MSSSQL 2K SP3 and that's upgraded the 
> MSSQL ODBC driver to version 2000.81.9031.38 but that's not 
> made any difference.
> 
> Help!  Is this a problem in DBI, DBD::ODBC, ODBC, or the 
> MSSQL ODBC driver?  Anyone got a work-round other than simply 
> ignoring the error?

Try using $dbh->do() and see if that works, rather than prepare() and
execute() separately.  Please let me know and if that fails too, send me a
DBI trace (level 9).

Thanks,

Jeff



Reply via email to