I want to define a trigger which will concat a numeric value with some characters and followed this Question How to make MySQL table primary key auto increment with some prefix as help but I am getting the error 1064.
mysql> desc autoid.
+-------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+----------------+
| ID | int(10) | NO | PRI | NULL | auto_increment |
+-------+---------+------+-----+---------+----------------+
This is my table for the auto increment ID
mysql> desc company_warehouse.
+----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| ID | varchar(12) | NO | PRI | | |
| PRODUCT_NAME | varchar(30) | YES | | NULL | |
| QTY | int(6) | YES | | NULL | |
| PRICE_PER_UNIT | decimal(10,2) | YES | | NULL | |
+----------------+---------------+------+-----+---------+-------+
This is the main table where the ID will be stored as 'p1','p2',...
mysql> CREATE TRIGGER tg_company_warehouse
-> BEFORE INSERT ON company_warehouse
-> FOR EACH ROW
-> BEGIN
-> INSERT INTO autoid VALUES(NULL);
-> SET NEW.ID = CONCAT('P',LPAD(LAST_INSERT_ID(),1,''));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
->
This is where I am getting the error while defining the trigger. I had changed my default Delimiter also to '.'