# How to fix this Trigger for a Percona Mysql database?

**URL:** <https://forums.percona.com/t/how-to-fix-this-trigger-for-a-percona-mysql-database/7241>\
**Category:** Percona Server for MySQL 5.6\
**Created:** [October 14, 2019, 9:47am UTC](https://forums.percona.com/t/how-to-fix-this-trigger-for-a-percona-mysql-database/7241 "2019-10-14T09:47:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KenobiShan](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@KenobiShan](https://forums.percona.com/u/KenobiShan)\
**Post date:** [October 14, 2019, 9:47am UTC](https://forums.percona.com/t/how-to-fix-this-trigger-for-a-percona-mysql-database/7241/1 "2019-10-14T09:47:04Z")

</div>

I have written a TRIGGER with SELECT but I am getting three errors:

1-SELECT IS NOT VALID AT THIS POSITION FOR THIS SERVER VERSION, EXPECTING ‘(’, WITH".  
At line 4

2-concat is no valid input…  
At line 5

3-END is no valid at this position…

CREATE DEFINER=`root`@`localhost` TRIGGER `user_AFTER_INSERT` AFTER INSERT ON `user`  
FOR EACH ROW  
BEGIN  
SELECT schema INTO @schema FROM Company WHERE Id = NEW.idCompany;  
SET @sql = CONCAT(‘INSERT INTO `', &#64;schema, '`.`Users` (id, username, dateBirth, idCompany) VALUES(?, ?, ?, ?)’;  
PREPARE stmt FROM @sql;  
SET @id = NEW.id;  
SET @username = NEW.username;  
SET @dateBirth = NEW.dateBirth;  
SET @idCompany = NEW.idCompany;  
EXECUTE stmt USING @id, @username, @dateBirth, @idCompany;  
DEALLOCATE PREPARE stmt;  
END

Server version: 5.6.41-84.1 - Percona Server (GPL), Release 84.1, Revision b308619
