aspose file tools*
The moose likes JDBC and the fly likes SQL Trigger failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Trigger failure" Watch "SQL Trigger failure" New topic
Author

SQL Trigger failure

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

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

Joined: Dec 20, 2006
Posts: 2510
    
  10

Hi.

What happens? Any error messages? What fails?

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

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
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8


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

Joined: Aug 31, 2006
Posts: 355

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

Joined: Dec 20, 2006
Posts: 2510
    
  10

Ah Yes. You inserted the record before the trigger was created. Now I see it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL Trigger failure