MSSQL through ODBC does not like unfinished statements - make sure we finish the...
Peter Rabbitson [Sun, 24 May 2009 08:47:03 +0000 (08:47 +0000)]
(This worked before because of the automatic retry on exception, essentially running any select after insert twice)

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;
 }