I'm having a small issue.
I want to do an insert in a table with a timestamp field called date in MySQL.
if I do a regular insert using a query with str_to_date, it works nicely. however, my program does not support using functions in the queries. so I need to find another way doing it, I was thinking about using a trigger, such as :
DELIMITER //
CREATE TRIGGER audit_oracle_date
BEFORE INSERT ON audit_oracle FOR EACH ROW
BEGIN
SET NEW.date = STR_TO_DATE(NEW.date, "%d %b %Y %H:%i:%s");
END
//
DELIMITER ;
but it does not work. the trigger is created, but when trying to enter a query like :
insert into audit_oracle values("20 Jan 2017 18:01:25","IFOMCP00","sdfdsfds","zerzerez","aaaa","SYSDBA","1","'select * from bla'","ddd","eee","2")
it gives me an error message saying "date field cannot be NULL"
any idea on how to code this trigger please ?
a regular, working query (with str_to_date) is for example :
insert into audit_oracle values(str_to_date("20 Jan 2017 18:01:25", "%d %b %Y %H:%i:%s"),"IFOMCP00","sdfdsfds","zerzerez","aaaa","SYSDBA","1","blabla","ddd","eee","2")
thanks again ! regards,
str_to_dateif needed)