MySQL Forums
Forum List  »  Triggers

Re: Help with a trigger
Posted by: Robert Wiglesworth
Date: August 11, 2015 09:35AM

I think this is everything:


CREATE TABLE IF NOT EXISTS `Events` (
`ID` varchar(32) NOT NULL DEFAULT '',
`UTC` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`Parent` varchar(32) NOT NULL,
`Locked` tinyint(1) NOT NULL DEFAULT '0',
`Creator` varchar(32) DEFAULT NULL,
`CName` text,
`Name` varchar(64) DEFAULT NULL,
`Date` date DEFAULT NULL,
`Location` tinytext,
`SubVenue` tinytext,
`GroupID` mediumint(32) unsigned zerofill DEFAULT NULL,
`Details` text,
`DetailsPrint` text,
`PaidCode` varchar(15) DEFAULT NULL,
`Paid` int(11) DEFAULT '0',
`Category` enum('Sports','Recreation','Business','Entertainment','Health','Education','Civic','Community','Religion') NOT NULL,
`Papers` set('GrandTerrace','Redlands','LomaLinda','Colton','SanBernardino','MorenoValley','DEV') DEFAULT NULL,
`LastPublish` varchar(128) DEFAULT NULL,
`Payed` set('0','GrandTerrace','Redlands','LomaLinda','Colton','SanBernardino','MorenoValley','All','Dev') DEFAULT '0',
`Time_Start` time DEFAULT NULL,
`Time_End` time NOT NULL DEFAULT '00:00:00',
`lat` float DEFAULT NULL,
`lng` float DEFAULT NULL,
`Age` text,
`Phone` text,
`Email` varchar(256) DEFAULT 'None Provided',
`Website` varchar(256) DEFAULT NULL,
`Recur` varchar(128) DEFAULT NULL,
`Interval` varchar(128) DEFAULT NULL,
`EveryXdays` varchar(128) DEFAULT NULL,
`Proofed` tinyint(1) NOT NULL,
`sproof` int(1) DEFAULT NULL,
`Visibility` int(12) DEFAULT '0',
`Remove` enum('','REMOVE THIS EVENT') NOT NULL,
`City` varchar(64) DEFAULT NULL,
`State` varchar(2) DEFAULT 'CA',
`Zip` int(11) DEFAULT NULL,
`Address` varchar(128) DEFAULT NULL,
`Contact` text,
`QR` blob,
`Image` blob,
PRIMARY KEY (`ID`),
FULLTEXT KEY `Location` (`Location`,`Address`,`City`,`State`),
FULLTEXT KEY `Search_IDX` (`Name`,`Details`,`Location`,`CName`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Triggers `Events`
--
DROP TRIGGER IF EXISTS `chk_paid`;
DELIMITER //
CREATE TRIGGER `chk_paid` BEFORE INSERT ON `Events`
FOR EACH ROW begin
declare chkcode char;
set @chkcode := (
SELECT concat(
CNG,
cast( Year( curdate( ) ) AS char ),
cast( weekofyear( curdate( ) ) AS char )
)
);

if new.PaidCode = @chkcode then
set new.paid = 1;
end if;
end
//
DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
1821
August 10, 2015 01:16PM
896
August 10, 2015 03:01PM
933
August 10, 2015 03:39PM
909
August 11, 2015 09:21AM
Re: Help with a trigger
900
August 11, 2015 09:35AM
949
August 11, 2015 11:38AM
907
August 11, 2015 11:43AM
868
August 11, 2015 12:25PM
887
August 15, 2015 09:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.