•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 363,805 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,601 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 696 | Replies: 1
![]() |
•
•
Join Date: May 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hello,
I'm having some sintax problems using PL/SQL in mySQL TRIGGERS.. I need some help please
.
Here is the code:
What could be wrong?? For testing I'm using phpmyadmin 2.11.1
Thanks
I'm having some sintax problems using PL/SQL in mySQL TRIGGERS.. I need some help please
. Here is the code:
CREATE TRIGGER modificou
AFTER UPDATE ON monitor
FOR EACH ROW
BEGIN
IF NOT EXISTS(SELECT estado_tmp FROM alteracoes WHERE id_tmp = OLD.id)
THEN
INSERT INTO alteracoes VALUES(OLD.id,NEW.estado);
ELSE
UPDATE alteracoes SET estado_tmp = NEW.estado WHERE id_tmp = OLD.id;
END IF;
END modificou;What could be wrong?? For testing I'm using phpmyadmin 2.11.1
Thanks
•
•
Join Date: Apr 2008
Posts: 249
Reputation:
Rep Power: 1
Solved Threads: 30
hi,
what is the error message?
Your trigger will be fired AFTER update, and, obviously, it were to catch update errors IF the record to be updated does not exist in your table. Well, if that record does not exist, update would not be execute, therefore (i believe so
) AFTER-update trigger will never be fired.
If you want to prevent failure, if a record to be inserted already exists (that would lead into duplicate primary key), you might use
krs,
tesu
what is the error message?
Your trigger will be fired AFTER update, and, obviously, it were to catch update errors IF the record to be updated does not exist in your table. Well, if that record does not exist, update would not be execute, therefore (i believe so
) AFTER-update trigger will never be fired.If you want to prevent failure, if a record to be inserted already exists (that would lead into duplicate primary key), you might use
sql Syntax (Toggle Plain Text)
INSERT INTO TABLE (...) VALUES (...) ON DUPLICATE KEY UPDATE ....
tesu
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Similar Threads
- Mysql (MySQL)
- Problem on IF STATEMENT on TRIGGER with MySql (MySQL)
- anybody give me suggestion for my final year project?? (PHP)
Other Threads in the MySQL Forum
- Previous Thread: MySQL Error 1064 when DELETEing
- Next Thread: ODBC configuration


Linear Mode