| | |
mySQL TRIGGER problem
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 1
Reputation:
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:
MySQL Syntax (Toggle Plain Text)
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: 296
Reputation:
Solved Threads: 42
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
![]() |
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
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql syntax techsupport thunderbird transparency virtualization





