# MySQL NEW. values are empty in AFTER INSERT trigger

**URL:** <https://forums.percona.com/t/mysql-new-values-are-empty-in-after-insert-trigger/5238>\
**Category:** Other MySQL® Questions\
**Created:** [November 26, 2016, 1:19pm UTC](https://forums.percona.com/t/mysql-new-values-are-empty-in-after-insert-trigger/5238 "2016-11-26T13:19:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sparksdr](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sparksdr](https://forums.percona.com/u/sparksdr)\
**Post date:** [November 26, 2016, 1:19pm UTC](https://forums.percona.com/t/mysql-new-values-are-empty-in-after-insert-trigger/5238/1 "2016-11-26T13:19:02Z")

</div>

I’ve been searching for 2 days on this one. I have a simple MySQL AFTER INSERT trigger to insert the new data into a 2nd table. However, when I run the trigger the 2nd table has all blank fields, except the foreign key ID from the 1st table…all other fields are empty. It seems the NEW. values in the insert trigger are blank when they should not be.

FIRST TABLE WITH THE AFTER INSERT TRIGGER:

CREATE TABLE IF NOT EXISTS `joom_cck_store_form_smart_mail_forward` (  
`id` int(10) unsigned NOT NULL,  
`mailbox_name` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL,  
`domain_name` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL,  
`forward_email_address` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL,  
`mailbox_comment` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL,  
`forward_to_persons_name` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL,  
`MailboxName` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL,  
PRIMARY KEY (`id`)  
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4\_unicode\_ci;

AFTER INSERT TRIGGER:

DELIMITER //

Create TRIGGER joom\_cck\_store\_form\_smart\_mail\_forward\_after\_insert  
AFTER INSERT  
ON joom\_cck\_store\_form\_smart\_mail\_forward FOR EACH ROW

BEGIN

DECLARE zDBname varchar(100);

– Insert record into main smart mail forward system table  
INSERT INTO zEmailForward(source\_id, mailbox\_name, domain\_name, comment\_text, recipient\_email\_address, recipient\_name)  
VALUES (NEW.id, NEW.mailbox\_name, NEW.domain\_name, NEW.mailbox\_comment, NEW.forward\_email\_address, NEW.forward\_to\_persons\_name);

END; //

DELIMITER ;

RESULT AFTER INSERTING A NEW ROW IN THE PRIMARY TABLE

The row in the primary table saves fine with all values filled in. The AFTER INSERT trigger runs and inserts a row in the second table (zEmailForward). However, only the source\_id field from the prmary table has a value in the zEmailForward table; all other columns are blank in zEmailForward. The NEW. values in the trigger are all blank, even though they should not be.

# =================================================================== PRIMARY TABLE (joom\_cck\_store\_form\_smart\_mail\_forward) ROW:

id MailboxName domain\_name forward\_email\_address mailbox\_comment forward\_to\_persons\_name  
10 Test [domain.com](http://domain.com) [test&#64;testemail.com](mailto:test&#64;testemail.com) this is a test Test Person

# =================================================================== 2nd TABLE (zEmailForward) ROW CREATED BY THE AFTER INSERT TRIGGER:

ID source\_id MailboxName domain\_name recipient\_email\_address comment\_text recipient\_name  
1 10

So you can see the ID from joom\_cck\_store\_form\_smart\_mail\_forward copied to the source\_id of zEmailForward field just fine…but all other fields in zEmailForward are blank.

===================================  
Database server information

Server: Localhost via UNIX socket Server type: Percona Server Server version: 5.6.31-77.0-log - Percona Server (GPL), Release 77.0, Revision 5c1061c Protocol version: 10 Server charset: UTF-8 Unicode (utf8)

==================================================

Any ideas why this is happening?

Thank you.
