Mysql Trigger Update & Insert

18th Mar 2011 at 11:21 AM | Posted in Uncategorized | Leave a comment

SHOW TRIGGERS;

CREATE TABLE `employees` (  `employeeNumber` int(11) NOT NULL,  `lastName` varchar(50) NOT NULL,  `firstName` varchar(50) NOT NULL,  `extension` varchar(10) NOT NULL,  `email` varchar(100) NOT NULL,  `officeCode` varchar(10) NOT NULL,  `reportsTo` int(11) default NULL,  `jobTitle` varchar(50) NOT NULL,  PRIMARY KEY  (`employeeNumber`))

CREATE TABLE employees_audit ( id int(11) NOT NULL AUTO_INCREMENT, employeeNumber int(11) NOT NULL, lastname varchar(50) NOT NULL,
changedon datetime DEFAULT NULL, action varchar(50) DEFAULT NULL, PRIMARY KEY (id) )
Insert:

DROP TRIGGER before_employee_update;DELIMITER $$CREATE TRIGGER before_employee_update BEFORE UPDATE ON employeesFOR EACH ROW BEGININSERT INTO employees_auditSET action = ‘update’,lastname = OLD.lastname,changedon = NOW(); END$$DELIMITER ;
Update:

DROP TRIGGER before_employee_update;DELIMITER $$CREATE TRIGGER before_employee_update BEFORE UPDATE ON employeesFOR EACH ROW BEGINUPDATE employees_auditSET action = ‘update’,employeeNumber = NEW.employeeNumber,lastname = NEW.lastname,changedon = NOW() WHERE employeeNumber=NEW.employeeNumber; END$$DELIMITER ;

Advertisements

2010 in review

6th Jan 2011 at 6:40 PM | Posted in Uncategorized | Leave a comment

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads This blog is doing awesome!.

Crunchy numbers

Featured image

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 2,700 times in 2010. That’s about 6 full 747s.

In 2010, there were 57 new posts, not bad for the first year! There were 62 pictures uploaded, taking up a total of 38mb. That’s about a picture per week.

The busiest day of the year was February 20th with 65 views. The most popular post that day was AJAX Introduction.

Where did they come from?

The top referring sites in 2010 were sourav.co.nr, google.co.in, cgaskell.wordpress.com, theonlinegk.wordpress.com, and statistics.bestproceed.com.

Some visitors came searching, mostly for general knowledge about human body, countries capitals and currencies, name the company whose c.e.o was chosen as the manager of the century by fortune magazine?, and general knowledge human body.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

AJAX Introduction January 2010

2

General Knowledge- Human Body February 2010

3

C Program-Call By value& Call By Reference(Swaping Program) March 2010

4

GK-CRICKET(India) February 2010

5

Drupal: Add module for Local languages March 2010

Blog at WordPress.com.
Entries and comments feeds.