IBM Support

SQL0407N when trying to insert an empty string in to a NOT NULL column

Troubleshooting


Problem

An empty string is not a NULL value in DB2, but getting the follwing error during insert of an empty string into a NOT NULL column. SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=5, COLNO=0" is not allowed. SQLSTATE=23502

Symptom

C:>db2 "create table t2(col1 varchar(20) not null)"
DB20000I The SQL command completed successfully.

C:>db2 "insert into t2 values('')"
DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:
SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2,TABLEID=5, COLNO=0" is not allowed. SQLSTATE=23502

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Routines (SP \u0026 UDF) - SQL","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;10.1;10.5;11.1","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

To view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use the link to actual document below to access the full document. You will be asked to log on if you are not already logged in. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

More support for:
Db2 for Linux, UNIX and Windows

Software version:
9.7, 9.5, 10.1, 10.5, 11.1

Operating system(s):
AIX, HP-UX, Linux, Solaris, Windows

Document number:
518745

Modified date:
01 May 2025

UID

swg21689789

Manage My Notification Subscriptions