From: Brian McCauley <[EMAIL PROTECTED]>
> 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 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.

What does it do if you change the $db->prepare like this:

        my $sth = $db->prepare('GO CREATE VIEW WIBBLE AS SELECT 1 AS WUBBLE 
GO');

?

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery

Reply via email to