Transaction object
The only thing you can do with the transaction object is the .executeSql() method, as far as I can tell. I can not find any properties of this object.
Error object
The error object has a .code property that contains a number. You can either check the numerical value (see My initial question above), or use something like:
if (error.code == error.DATABASE_ERR) alert('nasty database error')
The .message property is a string and may return something like this:
- failed to prepare statement (1 near "wibble": syntax error)
- failed to prepare statement (1 there is no such table: MyyTable)
- failed to prepare statement (1 table MyTable does not have a column MyColunm)
- failed to execute instruction (failure 19 restrictions)
Other posts are possible! These are just the few that I noticed when debugging in Chrome. I notice that in Phonegap the messages are shorter: "there is no such table: MyyTable"
There are two sets of success / error callbacks
Also note that the first call to .transaction() has another database error callback. Only an error object will be returned to your function (without a transaction object).
The .code error will be zero, and the .message will be a "statement callback caused by a callback with an exception or expression error, does not return false."
So remember that you are calling callbacks (the function specified inside .executeSql , for example my statement_error in the sample code of my source question) returns true or false depending on whether you want a transaction error callback (the second function is mentioned inside .transaction ) The success callback that you specified (the third inside .transaction ) will be triggered if you return true (or return nothing).
Magnus smith
source share