tags:

views:

77

answers:

3

I'm working on a VB6 executable that uses ODBC to update a DB2 Table. When trying to update a row that does not exist the program does not throw an error as would be expected. Why would this happen?

objAdoConn.Execute("Update T1234 Set A = 'X' Where B = 'y'");
+3  A: 

From a SQL point of view, there is nothing wrong with that command - it just doesn't update anything, which is a perfectly valid outcome.

anon
That's the reason
tekBlues
+3  A: 

Because this is a valid SQL statement that results in "0 rows affected". Which is success.

GSerg
+2  A: 

The other answers are correct: it's a valid SQL statement that just doesn't affect any records. If you want to know how many records are affected, use the optional RecordsAffected parameter like this:

Dim n As Long
objAdoConn.Execute("Update T1234 Set A = 'X' Where B = 'y'", n)
If n=0 Then MsgBox "No records affected!"
MarkJ