# Database Discussions > IBM DB2 >  Auto Number troubles

## austinl

I'm trying to insert a new row into a DB2 table using a simple insert statement.  I specify all of the collumns and values, but exclude the first column (the auto number field).  I was expecting it to add all the fields, and automatically add the incremented value to the autonumber field.  Any comments on how to get this working?  Here is the error i get:

System.Data.Odbc.OdbcException: ERROR [23502] [IBM][CLI Driver][DB2/6000] SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=8, TABLEID=2, COLNO=0" is not allowed.

----------


## Anbu

I have no idea, how you have defined the Auto number column...

Try this:

CREATE TABLE EMPLOYEE 
(EMPNO INT GENERATED ALWAYS AS IDENTITY,
NAME CHAR(10), SALARY INT,
BONUS INT, PAY INT);

INSERT INTO EMPLOYEE (NAME, SALARY, BONUS, PAY) VALUES('XXXX', 2000, 200, 2200);
INSERT INTO EMPLOYEE (NAME, SALARY, BONUS, PAY) VALUES('YYYY', 5000, 555, 5555);
INSERT INTO EMPLOYEE (NAME, SALARY, BONUS, PAY) VALUES('ZZZZ', 1000, 100, 1100);

SELECT * FROM EMPLOYEE;

EMPNO       NAME       SALARY      BONUS       PAY        
          1 XXXX              2000         200        2200
          2 YYYY              5000         555        5555
          3 ZZZZ              1000         100        1100

  3 record(s) selected.

----------

