Why could "insert (...) values (...)" not insert a new row?

Posted by nang on Stack Overflow See other posts from Stack Overflow or by nang
Published on 2010-06-07T10:12:39Z Indexed on 2010/06/07 11:02 UTC
Read the original article Hit count: 109

Filed under:
|
|
|

Hi, I have a simple SQL insert statement of the form:

insert into MyTable (...) values (...)

It is used repeatedly to insert rows and usually works as expected. It inserts exactly 1 row to MyTable, which is also the value returned by the Delphi statement AffectedRows:= myInsertADOQuery.ExecSQL.

After some time there was a temporary network connectivity problem. As a result, other threads of the same application perceived EOleExceptions (Connection failure, -2147467259 = unspecified error). Later, the network connection was reestablished, these threads reconnected and were fine.

The thread responsible for executing the insert statement described above, however, did not perceive the connectivity problems (No exceptions) - probably it was simply not executed while the network was down. But after the network connectivity problems myInsertADOQuery.ExecSQL always returned 0 and no rows were inserted to MyTable anymore. After a restart of the application the insert statement worked again as expected.

For SQL Server, is there any defined case where an insert statment like the one above would not insert a row and return 0 as the number of affected rows? Primary key is an autogenerated GUID. There are no unique or check constraints (which should result in an exception anyway rather than not inserting a row).

Are there any known ADO bugs (Provider=SQLOLEDB.1)?

Any other explanations for this behaviour?

Thanks, Nang.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server