[EMAIL PROTECTED] wrote:
Hi all,
I am a MySQL and in fact SQL newbie.
I am trying to write java code that will help me determine a couple of error conditions.
I want to be able to find out if, after I have done an insert, if the values that I entered are valid. Interestingly, when I entered clearly invalid non numeric data into bigint fields, it seemed to not generate an error. So I guess the first issue is why not, and the second is, is there a way to prevent the system from accepting an incompatible type. I know all this can be done at the JDBC level but this is an extra layer of security that would be helpful in the app I am writing.
To support non-transactional tables, all columns in mysql have defaults, so you need to do your validity checking in your code before you insert. See <http://dev.mysql.com/doc/mysql/en/Design_Limitations.html> and <http://dev.mysql.com/doc/mysql/en/constraint_NOT_NULL.html> for more.
The second issue is similar. How can I find out if a delete request failed because the key field could not be found?
DELETE removes all rows which match your WHERE clause. It returns the number of rows removed. If no rows match, nothing is deleted. That is not an error or failure, and 0 is returned. See <http://dev.mysql.com/doc/mysql/en/DELETE.html> for more.
Generally speaking, is the error handling doc for MySQL kinda weak, or am I just not looking in the right place? I printed out the error codes, but they are not really documented, and dont seem to address my issues.
As you don't seem to be getting any errors, I'm not sure how error codes are relevant. Are you trying to work backward from the errors to figure out correct/incorrect usage? If so, I'd recommend reading the manual for correct usage instead. Or did you mean something else?
Hank Williams
Michael
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]