activerecord-jdbc-adapter icon indicating copy to clipboard operation
activerecord-jdbc-adapter copied to clipboard

MSSQL - JDBCError: A result set was generated for update

Open petermumford opened this issue 9 years ago • 5 comments

I am only getting the error when I do any kind of insert statement. The error is coming from the exec_insert method. I've got the transaction from the SQL Profiler tool, which you can see below and I think I am right in saying that the problem has something todo with the select statement after the insert. As you can see this returns a single row column with a column name of GENERATED_KEYS. However, I really can't see why this could be the problem as the exec_insert method isn't really doing anything special.

ERROR:: ActiveRecord::JDBCError: com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update

INSERT INTO [beers] ([priority]) VALUES (1) select SCOPE_IDENTITY() AS GENERATED_KEYS

I've been having this issue for a while now and need some help. If anyone can point me in the right direction or try something I'd much appreciate it. Please let me know if you need any specific information that might help you.

Versions:

  • activerecord-jdbc-adapter: 1.3.11
  • SQL Server: 12.0.4213.0
  • Rails: 4.1.0
  • JRuby 1.7.12

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/30764683-mssql-jdbcerror-a-result-set-was-generated-for-update?utm_campaign=plugin&utm_content=tracker%2F136963&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F136963&utm_medium=issues&utm_source=github).

petermumford avatar Feb 11 '16 16:02 petermumford

I've just tried on a different version of SQL Server (10.0) and everything seems to be working. So maybe its a configuration issue?

petermumford avatar Feb 12 '16 14:02 petermumford

probably (or a driver behaviour), recommend you look into as getting multiple SQL-Server versions setup is quite time consuming and personally do not have much time to be looking into a DB that I do not care.

kares avatar Feb 22 '16 17:02 kares

I am having a similar problem over here:

https://github.com/jruby/activerecord-jdbc-adapter/issues/736

In my case, #replace_limit_offset! is clobbering my UPDATE statement with a SELECT! Could be same for you....

Not sure why changing the server version fixed the problem for you. Very interesting outcome...

rob99 avatar Jul 27 '16 00:07 rob99

I have had same problem with: Rails 3 JRuby 1.6 MSSQL 2008

I realized that the error disapear on restart the torquebox

Has anyone a workaround for that?

dtelaroli avatar Feb 05 '18 10:02 dtelaroli

I was using the parameter SET NOCOUNT ON and forgetting the SET NOCOUNT OFF

https://stackoverflow.com/questions/22360730/sqlserverexception-a-result-set-was-generated-for-update

dtelaroli avatar Feb 06 '18 17:02 dtelaroli