Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Trigger failure

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Could someone please tell me why sql trigger in the below code fails. Please guide me with corrected trigger code. Database is Java DB.
Thanks in advance!
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

What happens? Any error messages? What fails?

Regards, Jan
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply!
The trigger fails to work. There are no error messages.
My attempt is simple:
Whenever I insert a value in table one, immediately the same data should be inserted in table two as well.

I'm new to SQL. I'm still trying to know why it has failed.
Thanks in advance for any help.
 
Paul Clapham
Sheriff
Posts: 21321
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I don't think that's the correct format for an INSERT statement which doesn't assign values to all columns.
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been more than 12 hours that I've started working with this small program. Yes, I just now got to know my mistake!
There is nothing wrong with the code but the order of statements. The below code generates what I wanted:

Insert statements should come after trigger.
Thanks for your replies!
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah Yes. You inserted the record before the trigger was created. Now I see it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic