MSSQL through ODBC does not like unfinished statements - make sure we finish the...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC / Microsoft_SQL_Server.pm
index 3c18a3c..5aa1f0c 100644 (file)
@@ -19,7 +19,10 @@ sub _execute {
     my ($op) = @_;
 
     my ($rv, $sth, @bind) = $self->dbh_do($self->can('_dbh_execute'), @_);
-    $self->{_scope_identity} = $sth->fetchrow_array if $op eq 'insert';
+    if ($op eq 'insert') {
+      $self->{_scope_identity} = $sth->fetchrow_array;
+      $sth->finish;
+    }
 
     return wantarray ? ($rv, $sth, @bind) : $rv;
 }