Oracle ORA-01400 on empty string insert: Oracle treats '' as NULL
Developers moving from MySQL, PostgreSQL or SQL Server can hit an ORA-01400 error when inserting an empty string into a NOT NULL column in Oracle. The author reproduced the problem on Oracle AI Database 26ai Free (23.26.3) using a customers table where the phone column was NOT NULL. The query output showed that '' IS NULL evaluates to true and that the length of an empty string is NULL, so Oracle does not distinguish '' from NULL. The suggested fixes are to allow NULL in the column if the value is optional, or to have the application send a real value if it is required. After the column was changed to allow NULL, the insert succeeded but stored a NULL rather than an empty string.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in