in reply to DBI DBD::ODBC, Create a table, drop its constraints, then recreate it again!

Here it appears you are only fetching one constraint, and so your sth is still "busy" when there are any constraints (you need to fetch once for each row, and then one more time to automatically "finish" the cursor so it's no longer "busy"):
my $sth = $dbh->prepare("SELECT constraint_name FROM INFORMATION_S +CHEMA.CONSTRAINT_COLUMN_USAGE WHERE TABLE_NAME = '$tbl'"); $sth->execute; my $temp = $sth->fetchrow_arrayref; foreach my $rel (@$temp) { next unless ($rel =~ /ID/); $dbh_tmp->do("ALTER TABLE $tbl DROP CONSTRAINT $rel"); }
Since you are only fetching one column, you can replace the prepare/execute/fetch with just (and since all the rows will be fetched, the statement won't stay "busy"):
my $temp = $dbh->selectcol_arrayref($your_sql_statement);

Replies are listed 'Best First'.
Re^2: DBI DBD::ODBC, Create a table, drop its constraints, then recreate it again!
by blackadder (Hermit) on Nov 25, 2009 at 14:51 UTC
    Hi,

    Thanks for the reply,it worked..