Reputation: 11
I'm trying to create a trigger which returns the current date. But I'm struggling to include Curdate() function in a string
DELIMITER $$
create trigger invalid_date
before insert on invoice
for each row
begin
if new.date_in <> CURDATE() then
signal sqlstate '45000' set message_text =
"TriggerError: The date_in date should be Curdate()" ;
end if ;
end$$
DELIMITER;
Doing it this way won't return the current date but rather just treat Curdate() as a string. My question is how do I include the Curdate() into the error message and actually return a date.
Upvotes: 1
Views: 47
Reputation: 1085
You can use CONCAT function to print date.
message_text = CONCAT("Your string: ", CURDATE())
Upvotes: 1