Skip to content

Instantly share code, notes, and snippets.

@onare
Created July 3, 2015 15:58
Show Gist options
  • Save onare/d3eec60636ae54ae0359 to your computer and use it in GitHub Desktop.
Save onare/d3eec60636ae54ae0359 to your computer and use it in GitHub Desktop.
AFTER INSERT TRIGGER
USE `veeva_new`;
DELIMITER $$
DROP TRIGGER IF EXISTS veeva_new.user_ai$$
USE `veeva_new`$$
CREATE DEFINER = CURRENT_USER TRIGGER `veeva_new`.`user_ai` AFTER INSERT ON `user` FOR EACH ROW
BEGIN
INSERT INTO pdone.reps
(veeva_rep_id,territories_id,display_name,avatar_url,rep_type,username,first,last,title,bio,phone,email,inactive,lastLoginAt,lastSyncAt,repTokenId,createdAt,updatedAt)
select
NEW.id,
null as territories_id,
test.LCAPITAL(CONCAT(NEW.lastname,' ',NEW.firstname)) as display_name,
'default avatar url' as avatar_url,
'VEEVA' as rep_type,
NEW.username,
NEW.firstname as first,
NEW.lastname as last,
null as title,
null as bio,
null as phone,
NEW.email,
'' as inactive,
null as lastLoginAt,
NEW.lastmodifieddate as lastSyncAt,
null as repTokenId,
now() as createdAt,
now() as updatedAt;
END
$$
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment