Exforsys

Online Training

Struck with Updation

This is a discussion on Struck with Updation within the MySQL forums, part of the Database category; I have a table designed named as employee. In that various columns and one of the attributes in these employee ...


Go Back   Exforsys > Database > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-22-2007, 06:07 AM
Senior Member
 
Join Date: Apr 2006
Posts: 145
Rahulbatra is on a distinguished road
Exclamation Struck with Updation

I have a table designed named as employee. In that various columns and one of the attributes in these employee table is up_date. I am struck with a task namely I want to have this up_date files getting updated with current date as soon as a user updates the table. The column must get updated automatically without any intervention by users. How can I achieve this? Kindly help me out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-28-2007, 02:23 PM
Senior Member
 
Join Date: Apr 2006
Posts: 122
rachelle is on a distinguished road
You can use the triggering concept that will help you to fire the trigger and update the column up_date only when the user updates the table. I have given below the skeleton format of trigger you can make use to finish your process.
CREATE TRIGGER triggername ON databasename.tablename
FOR UPDATE
AS
update tablename
set up_date=getdate()
from tablename
inner join sample on sample.PKCol = tablename.PKCol

In the above the table name for you is employee. The getdate() will help to get the current date inserted into the column up_date on the employee table.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new questions
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Struck with Formatting Adrian C and C++ 0 06-08-2007 03:15 PM
Struck with this Task Rahulbatra C and C++ 1 05-28-2007 02:12 AM
Struck Abstract with Abstract Class priyaraji C and C++ 2 05-01-2007 09:04 AM


All times are GMT -4. The time now is 03:18 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.