File: testerrhandler.pl

package info (click to toggle)
libdbd-odbc-perl 1.37-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,272 kB
  • sloc: perl: 7,932; ansic: 5,991; makefile: 33; sql: 8
file content (27 lines) | stat: -rw-r--r-- 698 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use strict;
# $Id: testerrhandler.pl 11680 2008-08-28 08:23:27Z mjevans $


use DBI;

sub err_handler {
   my ($state, $msg) = @_;
   # Strip out all of the driver ID stuff
   $msg =~ s/^(\[[\w\s]*\])+//;
   print "===> state: $state msg: $msg\n";
   return 0;
}

my $dbh = DBI->connect("dbi:ODBC:PERL_TEST_SQLSERVER", $ENV{DBI_USER}, $ENV{DBI_PASS})
       || die "Can't connect: $DBI::errstr\n";

$dbh->{odbc_err_handler} = \&err_handler;
$dbh->{odbc_async_exec} = 1;
print "odbc_async_exec is: $dbh->{odbc_async_exec}\n";

my $sth;
$sth = $dbh->prepare("dbcc checkdb(model)") || die $dbh->errstr;
$sth->execute                               || die $dbh->errstr;
$sth->finish;
$dbh->disconnect;