Strange error code behaviour

Jun 18, 2013 at 9:01 AM
Edited Jun 18, 2013 at 9:50 AM
Have a table Rubriek with content
CId RId Rubriek
1 1 ">> Test value !!"
1 2 "Test value"
RId = primary unique key, autoincrement.

I execute the following statement:
update Rubriek set Rubriek = 'A>> Test value !!' where Rubriek.Rid = 1

sqlite3preparev2 works as expected and returns 0
sqlite3step returns 21 (Library used incorrectly) whereas sql3errcode at the same time returns 0. You can imagine that I'm getting quite confused as to what the proper return code is, especially when sqlite3changes is returning 0 lines affected.

Querying the database again shows the unmodified records as expected based on affected rows.

I've looked at your demo source code and noticed you don't have an update stament in there. I noticed how with an insert statment you don't do any error code checking. So I tried the same with the update statement.

But still no update is performed. Affected rows stays 0 and querying the database shows unmodified records. I can't see anything wrong with my statement, but please enlighten me, 'cause I'm not an sql expert.

Have also tried the same actions with an insert statement, but got the same kind of result. I performed the statement INSERT INTO Rubriek (CId,Rubriek) VALUES (1,'TEST').

Hope you can hint me to what's going wrong.
Btw there are no locking issues I've found. Nor is the db in use by another application.
Jun 18, 2013 at 12:36 PM

I can only think that there is a call sequence error between the sqlite3preparev2 and sqlite3step - perhaps you are not using the right command handle, or something.

Could you perhaps post a bit more of your code?

Jun 19, 2013 at 10:49 AM

Your reply got me thinking. I had created some wrapper functions around some SQLitet3xxx functions. So I investigated all parameters passed, but they were correctly passed. No errors there as I already expected. All went wrong when I messed up a vba statement upon which Excel terminated. After fixing the error I continued and the odd results kept appearing. No matter what I tried to do (INSERT, UPDATE, CREATE...) everything failed except SELECT.

This brought me in mind, that the same had happened yesterday, but since I started coding a lot before starting another test, I had completely forgotten about it.

Conclusion: no problems with SQLite3, but with excel not freeing memory properly after an error occurs.
Another conclusion: things are not always what they seem.

Thanks for the response.

Jun 19, 2013 at 10:56 AM
I'm glad it's sorted out.