Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trigger Error

 
Greenhorn
Posts: 18
IBM DB2 Oracle MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the error in below trigger.



 
Ranch Hand
Posts: 153
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems your insert statement is has errors Ex
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're missing BEGIN keyword after the FOR EACH ROW clause.

The entire syntax diagram for the CREATE TRIGGER statement is here (true, quite overwhelming, but sometimes indispensable). A guide on triggers (containing some examples) can be found here.

However, your insert syntax is also wrong. Generally, syntax statements look likeThe values can be literals, variables or expressions in general.

And lastly, it is not entirely clear what NUM1 and NUM2 are. If they are columns in the TESTING table, you need to access them using the :new variable, eg. :new.num1.
 
Praveen Kumar Singh
Greenhorn
Posts: 18
IBM DB2 Oracle MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks it got fixed after i change the code.

CREATE OR REPLACE TRIGGER ADDING_NEW
BEFORE INSERT ON TESTING
FOR EACH ROW
BEGIN
:NEW.TOTAL:=:NEW.NUM1+:NEW.NUM2;
END;
 
I think I'll just lie down here for a second. And ponder this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic