Reputation: 361
despite none NULL
value in column preptime2
(value = 7), SQLite is throwing exception:
NOT NULL constraint failed.
The excerpt below is showing
(1) value in menucard_meal.preptime2
(value = 7)
and then
(2) the try to INSERT INTO
same data in table orders_meal which throws the error.
sqlite> select preptime2 from menucard_meal where id = 32;
7
sqlite> INSERT INTO orders_meal SELECT * from menucard_meal where id = 32;
Error: NOT NULL constraint failed: orders_meal.preptime2
sqlite>
Has someone any idea what happens here? Thnx
Upvotes: 0
Views: 394
Reputation: 164089
In this statement:
INSERT INTO orders_meal
SELECT * from menucard_meal
where id = 32;
there are 2 tables involved: orders_meal
and menucard_meal
.
In the above statement you do not list the columns of either table.
This is not required but it is a good practice and usually it saves you from problems like (I suspect) this one.
List the columns for both tables and make sure that the corresponding columns are in the same order, like:
INSERT INTO orders_meal(column1, column2, columnforpreptime2, ...)
SELECT col1, col2, preptime2, ...
from menucard_meal
where id = 32;
Upvotes: 1