totn Oracle Error Messages

Oracle / PLSQL: ORA-01400 Error Message

Learn the cause and how to resolve the ORA-01400 error message in Oracle.

Description

When you encounter an ORA-01400 error, the following error message will appear:

  • ORA-01400: cannot insert NULL into ("SCHEMA"."TABLE_NAME"."COLUMN_NAME")

Cause

You tried to insert a NULL value into a column that does not accept NULL values.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Correct your INSERT statement so that you do not insert a NULL value into a column that is defined as NOT NULL.

For example, if you had a table called suppliers defined as follows:

CREATE TABLE suppliers
( supplier_id number not null,
  supplier_name varchar2(50) not null );

And you tried to execute the following INSERT statement:

INSERT INTO suppliers
( supplier_id )
VALUES
( 10023 );

You would receive the following error message:

Oracle PLSQL

You have defined the supplier_name column as a NOT NULL field. Yet, you have attempted to insert a NULL value into this field.

You could correct this error with the following INSERT statement:

INSERT INTO suppliers
( supplier_id, supplier_name )
VALUES
( 10023, 'IBM' );

Now, you are inserting a NOT NULL value into the supplier_name column.