From: Peter Rabbitson Date: Sun, 24 May 2009 08:47:03 +0000 (+0000) Subject: MSSQL through ODBC does not like unfinished statements - make sure we finish the... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77af494bb1ddc46a7a8eba467ab189daacccf32c;p=dbsrgits%2FDBIx-Class-Historic.git MSSQL through ODBC does not like unfinished statements - make sure we finish the scope identity retrieval (This worked before because of the automatic retry on exception, essentially running any select after insert twice) --- diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm index 3c18a3c..5aa1f0c 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -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; }