I am attempting to populate an SQL table through reading text files via bash to hand off to the table. I have it all working except when trying to add a null value to a datetime field.
mysql --host 10.100.10.19 --port 3306 -utest -ptest << EOF
INSERT INTO imaging.imagestatus (StatusDate, FileName, FolderName, Status, User, CaptureDate, Kind, Preview) VALUES ('2013-05-01T15:25:55', 'fileName1', 'folderName1', 'Status1', 'User1', 'NULL', 'kind1', 'preview1');
EOF
I keep getting:
ERROR 1292 (22007) at line 1: Incorrect datetime value: 'NULL' for column 'CaptureDate' at row 1
for the value labeled 'NULL' which is a data type datetime in the table. I have tried the combinations '\N', '\N', 'NULL', 'null' and ' '
I started to use a temporary date: 00-00-00 00:00:00 but I want it to match other null entry formats or just a blank space in the table. Thanks for the help!
ANSWER-- As was implemented
The value in the text file name "NULL" that is pulled in can be swapped with a variable like a=NULL to get a correct NULL value for a datetime input.