Wish DB Error Codes

udg

Expert
Licensed User
Longtime User
Hi all,

we're used to rely on LastException to read what failed in our code. But when dealing with a DB (case at hand is MySQL) I'd like to receive a standard numeric code from it, something like:
xxx for "bad date format"
yyy for "bad syntax"
zzz for "db must be opened before.."

Probably a good solution could be having all the ExecQuery, ExecNoQuery functions return a success code but this will break all existing code, so maybe an extra function like ExecRetCode will be a better option.

I understand that most errors could be "static" in the sense they show at early development stage so you're supposed to clean them up in order to have a working prototype; in this case LastException.message would be probably enough.

But there are times the DB errors could be "dynamic", real time. What if your IT manager stops the DBMS for maintainance or any other reason? I'd like my code to receive a code meaning "DB unreachable" and decide whether to retry a few times or just tell the user and shut down (if that is an essential part of the program). Same for "too large result data set" or "timeout while executing last command" or whatever.

In conclusion, I'd like to receive some sort of "workable on" feedback when issuing a command to a DB.

What do you think?
 

udg

Expert
Licensed User
Longtime User
Neither does MySQL? Or any other SQL DB that is not SQLite?
Maybe you could envision a general error/status feedback scheme where SQLite is just one specific element, returning a fixed value. It could be a brand new object (common to the whole B4x platform) that we optionally instantiate along with the SQL or PoolConnection object when we'd like to deeply manage interaction with the DB. In it you pass whatever "low level" info the used interface gives you.
In case of SQLite we don't instantiate it or, if we do, we are prepared to receive a fixed value (e.g. 0 = all ok; -1 =something failed or even 0 = not applicable).

Sorry if my request is not clearly focused, I'm just thinking loud. BTW, if I'm the only one concerned with it, I guess you can dismiss it. Thanks anyway.

udg
 

udg

Expert
Licensed User
Longtime User
You have posted this request in B4A forum
Oooops... I looked for a "wish" section so I didn't take in consideration the forum. Sorry.
Please move the thread where you find it more appropriate for a general discussion.
 
Top