Oracle vs. MySQL, handling of values exceeding column width

errorhandling forms mysql oracle

Tue Dec 09 07:07:00 -0800 2008

Say you have a form that someone slapped together some ages ago, and that form has no maxlength attributes on its text input fields. Say also that you don’t have any JavaScript validation of said form wherein those field lengths would be checked upon submit. Say you likewise have no logic in your form processing script with knowledge of the appropriate length at which the storied form input should be curtailed.

Say indeed that an 80-character string has made its way all the way through to an attempted INSERT or UPDATE statement, and the length of its target column is, for example, 20.

If the database server upon which you’re forcing the bum data is MySQL, the first 20 characters of your 80-character string is magically snipped and placed snugly into its target column. If by some chance you have all of that sloppy markup and code sitting in front of Oracle, you instead get a big, angry error message about how naughty you are for attempting to put your heinously large string into a column where it obviously is not appropriate to be stored.

SQLSTATEHY000: General error: 12899 OCIStmtExecute: ORA-12899: value too large for column

I don’t know who to be more annoyed at about this.

blog comments powered by Disqus