This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> CALL GetVoteID(1,1,@votes_id); | |
Query OK, 1 row affected (0.00 sec) | |
mysql> SELECT @votes_id votes_id; | |
+----------+ | |
| votes_id | | |
+----------+ | |
| 5 | | |
+----------+ | |
1 row in set (0.00 sec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE `veeva_new`; | |
DELIMITER $$ | |
DROP TRIGGER IF EXISTS veeva_new.address_vod__c_ai$$ | |
USE `veeva_new`$$ | |
CREATE DEFINER=`root`@`localhost` TRIGGER `veeva_new`.`address_vod__c_ai` AFTER INSERT ON `address_vod__c` FOR EACH ROW | |
BEGIN | |
DECLARE vCount INT(6) DEFAULT 0; | |
SET vCount=(SELECT COUNT(*) FROM pdone.targets WHERE targets.veeva_account_id=NEW.account_vod__c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DEFINER = CURRENT_USER TRIGGER `veeva_new`.`account_au` AFTER UPDATE ON `account` FOR EACH ROW | |
BEGIN | |
SET @TargetLastMod=(SELECT targets.lastSyncAt FROM pdone.targets WHERE targets.veeva_account_id=NEW.id LIMIT 0,1); | |
# [ IF EXISTS IN pdone.targets, UPDATE only if NEW.lastmodifieddate IS GREATER than @TargetLastMod ] | |
IF (NEW.lastmodifieddate > @TargetLastMod) THEN | |
INSERT INTO pdone.targets | |
(`veeva_account_id`,`veeva_timestamp`,`display_name`,`avatar_url`,`title`,`first`,`last`,`suffix`,`address1`,`address2`,`city`,`state`,`zip`,`phone`,`fax`,`target_type`,`npi`,`inactive`,`lastSyncAt`,`createdAt`,`updatedAt`) | |
SELECT | |
account.id AS veeva_account_id, | |
account.lastmodifieddate AS veeva_timestamp, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE `veeva_new`; | |
DELIMITER $$ | |
DROP TRIGGER IF EXISTS veeva_new.account_ai$$ | |
USE `veeva_new`$$ | |
CREATE DEFINER = CURRENT_USER TRIGGER `veeva_new`.`account_ai` AFTER INSERT ON `account` FOR EACH ROW | |
BEGIN | |
DECLARE vCount INT(6) DEFAULT 0; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE `PRUEBA`; | |
DROP function IF EXISTS `alpha`; | |
DELIMITER $$ | |
USE `PRUEBA`$$ | |
CREATE DEFINER=`root`@`localhost` FUNCTION `alpha`( | |
vStr CHAR(75)) RETURNS char(32) CHARSET latin1 | |
BEGIN | |
DECLARE vInd, vLen SMALLINT DEFAULT 1; | |
DECLARE vReturn CHAR(32) DEFAULT ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE `veeva_new`; | |
DELIMITER $$ | |
CREATE DEFINER=`root`@`localhost` TRIGGER `veeva_new`.`userterritory_ai` AFTER INSERT ON `userterritory` FOR EACH ROW | |
BEGIN | |
# [ VARIABLES DECLARATION ] | |
DECLARE vUserID VARCHAR(18) DEFAULT ''; | |
DECLARE vTerritoryRep VARCHAR(45) DEFAULT ''; | |
DECLARE vTerritoryLastMod DATETIME DEFAULT '0000-00-00 00:00:00'; | |
DECLARE vTerritoryCount INT(7) DEFAULT 0; #[060715.01] | |
# [ VARIABLES ASIGNATION ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DEFINER=`root`@`localhost` TRIGGER `veeva_new`.`userterritory_ai` AFTER INSERT ON `userterritory` FOR EACH ROW | |
BEGIN | |
# [ VARIABLES DECLARATION ] | |
DECLARE vUserID VARCHAR(18) DEFAULT ''; | |
DECLARE vTerritoryRep VARCHAR(45) DEFAULT ''; | |
DECLARE vTerritoryLastMod DATETIME DEFAULT '0000-00-00 00:00:00'; | |
DECLARE vTerritoryCount INT(7) DEFAULT 0; #[060715.01] | |
# [ VARIABLES ASIGNATION ] | |
SET vUserID =NEW.userid; | |
SET vTerritoryRep =(SELECT IFNULL(reps.territories_id,'N/A') FROM pdone.reps WHERE reps.veeva_rep_id=vUserID LIMIT 0,1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE `veeva_new`; | |
DELIMITER $$ | |
DROP TRIGGER IF EXISTS veeva_new.userterritory_ai$$ | |
USE `veeva_new`$$ | |
CREATE DEFINER=`root`@`localhost` TRIGGER `veeva_new`.`userterritory_ai` AFTER INSERT ON `userterritory` FOR EACH ROW | |
BEGIN | |
# [ VARIABLES DECLARATION ] | |
DECLARE vUserID VARCHAR(18) DEFAULT ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DEFINER=`root`@`localhost` TRIGGER `veeva_new`.`userterritory_ai` AFTER INSERT ON `userterritory` FOR EACH ROW | |
BEGIN | |
# [ VARIABLES DECLARATION ] | |
DECLARE vUserID VARCHAR(18) DEFAULT ''; | |
DECLARE vTerritoryRep VARCHAR(45) DEFAULT ''; | |
DECLARE vTerritoryLastMod DATETIME DEFAULT '0000-00-00 00:00:00'; | |
DECLARE vTerritoryCount INT(7) DEFAULT 0; #[060715.01] | |
# [ VARIABLES ASIGNATION ] | |
SET vUserID =NEW.userid; | |
SET vTerritoryRep =(select IFNULL(reps.territories_id,'N/A') from pdone.reps where reps.veeva_rep_id=vUserID LIMIT 0,1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DEFINER=`root`@`localhost` TRIGGER `veeva_new`.`userterritory_ai` AFTER INSERT ON `userterritory` FOR EACH ROW | |
BEGIN | |
# [ VARIABLES DECLARATION ] | |
DECLARE vUserID VARCHAR(18) DEFAULT ''; | |
DECLARE vTerritoryRep VARCHAR(45) DEFAULT ''; | |
DECLARE vTerritoryLastMod DATETIME DEFAULT '0000-00-00 00:00:00'; | |
DECLARE vTerritoryCount INT(7) DEFAULT 0; #[060715.01] | |
# [ VARIABLES ASIGNATION ] | |
SET vUserID =NEW.userid; | |
SET vTerritoryRep =(select IFNULL(reps.territories_id,'N/A') from pdone.reps where reps.veeva_rep_id=vUserID LIMIT 0,1); |
NewerOlder