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?
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?