From: "Martin J. Evans" <[EMAIL PROTECTED]>
> I haven't tried it in a long time (other than running make test) but
> from perldoc DBD::ODBC:
> 
>        odbc_async_exec
>            Allow asynchronous execution of queries.  Right now,
>            this causes a spin-loop (with a small "sleep") until
>            the sql is complete.  This is useful, however, if you
>            want the error handling and asynchronous messages (see the
>            err_handler) below.  See t/20SQLServer.t for an example of
>            this.

Sweeeeet. It works:

use DBI;

my $text = '';

my $dbh = DBI->connect('dbi:ODBC:jobodbc2', 'TMPJOBVIPERADMIN', 
'jobviper',
        {PrintError => 0,RaiseError => 1,LongReadLen => 65536,
        odbc_async_exec => 1,
        odbc_err_handler => sub {
                        my ($state, $msg) = @_;
                        # Strip out all of the driver ID stuff
                        $msg =~ s/^(\[[\w\s]*\])+//;
                        $text .= $msg."\n";
                        return 0;
                }
        });

$sth = $dbh->prepare("dbcc CHECKDB ('jobviper')");
$sth->execute;

print $text;

$dbh->disconnect();


It seems that the ->prepare() and ->execute() is necessary, it 
doesn't work with ->do().

Thanks, 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