MySQL Forums
Forum List  »  Triggers

Trigger Not Working
Posted by: Debopam Mitra
Date: October 02, 2011 02:57PM

I have a table as follows:

CREATE TABLE IF NOT EXISTS users(
uname VARCHAR(30) PRIMARY KEY,
pass VARCHAR(30) NOT NULL,
regDate DATE,
regTime TIME);


And a trigger to the table:


CREATE TRIGGER updtUsersDateTime
AFTER INSERT
ON users FOR EACH ROW
UPDATE users
SET regDate = curdate() and regTime=curtime()
where uname = NEW.uname;

But whenever I try inserting values to the table an error is being thrown which is as follows:

"ERROR 1442 (HY000): Can't update table 'users' in stored function/trigger because it is already used by statement which invoked this stored function/trigger."

With reference to post http://forums.mysql.com/read.php?99,114015 by Jamie, I have also tried using BEFORE instead of AFTER but the same problem persists.

I am very close to the submission of my project and will be very grateful if replied ASAP.

With Regards,

Debopam

Options: ReplyQuote


Subject
Views
Written By
Posted
Trigger Not Working
3121
October 02, 2011 02:57PM
1093
October 03, 2011 05:48PM


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.