On 11-Sep-2003 Jenda Krynicky wrote:
> 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().
It won't work with do() because do is for non-result-set generating SQL like
inserts etc and doesn't do the asynchronous stuff . Glad you have it working OK
though.
Martin
--
Martin J. Evans
Easysoft Ltd, UK
Development