I want to return error message when duplicate records occur, groupName is unique field in group table.
I make like this, how can I make error handleing whithout using mysql-get-diagnostics because the server I am working on is version 5.0.77-log.
DELIMITER //
CREATE PROCEDURE addNewGroup(IN groupName varchar(128), IN addedBy INT,OUT message varchar(128) )
BEGIN
insert IGNORE into `group`( `group_name`,`Date_time_ added`,`added_by`) values (groupName ,CURRENT_TIMESTAMP(),addedBy) ;
END //
DELIMITER ;
I want to return error message when duplication occur?
Try this method –
ROW_COUNT() function returns the number of inserted rows for the last statement.
In MySQL 5.5. you can use SIGNAL statement to generate a warning.