Thai Heng has asked for the wisdom of the Perl Monks concerning the following question:
my script as follows:DBD::ODBC::st execute failed: [Microsoft][SQL Server Native Client 10. +0] busy connection result another command (SQL-HY000) at dumpTableInf +oColumn.pl line 33
#!/usr/bin/perl -w # # ch06/tabledump: Dumps information about all the tables. use strict; use DBI; ### Connect to the database my $dbh = DBI->connect( "dbi:ODBC:SQLSERVER2008R2","sa","7354500", { RaiseError => 1 }); ### Create a new statement handle to fetch table information my $tabsth = $dbh->table_info(); ### Iterate through all the tables... while ( my ( $qual, $owner, $name, $type ) = $tabsth->fetchrow_array() + ) { ### The table to fetch data for my $table = $name; ### Build the full table name with quoting if required $table = qq{"$owner"."$table"} if defined $owner; ### The SQL statement to fetch the table metadata my $statement = "SELECT * FROM $table"; print "\n"; print "Table Information\n"; print "=================\n\n"; print "Statement: $statement\n"; ### Prepare and execute the SQL statement my $sth = $dbh->prepare( $statement ); $sth->execute(); #Attention the error my $fields = $sth->{NUM_OF_FIELDS}; print "NUM_OF_FIELDS: $fields\n\n"; print "Column Name Type Precision Scale Nul +lable?\n"; print "------------------------------ ---- --------- ----- --- +------\n\n"; ### Iterate through all the fields and dump the field information for ( my $i = 0 ; $i < $fields ; $i++ ) { my $name = $sth->{NAME}->[$i]; ### Describe the NULLABLE value my $nullable = ("No", "Yes", "Unknown")[ $sth->{NULLABLE}->[$i +] ]; ### Tidy the other values, which some drivers don't provide my $scale = $sth->{SCALE}->[$i]; my $prec = $sth->{PRECISION}->[$i]; my $type = $sth->{TYPE}->[$i]; ### Display the field information printf "%-30s %5d %4d %4d %s\n", $name, $type, $prec, $scale, $nullable; } ### Explicitly deallocate the statement resources ### because we didn't fetch all the data $sth->finish(); } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI sth can't run simultaneously for SQLServer 2008
by ig (Vicar) on Sep 17, 2013 at 03:43 UTC | |
by Thai Heng (Beadle) on Sep 17, 2013 at 06:35 UTC | |
|
Re: DBI sth can't run simultaneously for SQLServer 2008
by NetWallah (Canon) on Sep 17, 2013 at 05:26 UTC | |
|
Re: DBI sth can't run simultaneously for SQLServer 2008
by mje (Curate) on Sep 17, 2013 at 08:54 UTC |