Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 21st, 2003, 04:42 PM
Vortrex Vortrex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 Vortrex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
newbie Trigger problem

Hi, I've been trying to create a trigger in oracle 8i but oracle just hangs at a line marker and does nothing after i feed it the code to create the trigger.
I have the following tables
family(id, name, street, city, state, zipcode, reciprocity)
gift(sender_id, receiver_id, occasion, presentType, reciprocal, order_id)
and my trigger is the following.
Code:
CREATE TRIGGER handleReciprocity
AFTER INSERT ON gift
REFERENCING
      NEW ROW AS nt
FOR EACH ROW
      WHEN( ((SELECT reciprocity FROM family
             WHERE id = nt.receiver_id) = 'YES') AND
             NOT EXISTS ( SELECT * FROM gift
                          WHERE (sender_id = nt.receiver_id AND
                                 receiver_id = nt.sender_id AND
                                 occasion = nt.occasion AND
                                 reciprocal = 'YES')))
      INSERT INTO gift
             VALUES(nt.receiver_id, nt.sender_id, nt.occasion, nt.presentType, 'YES', nt.orderId + 1);

Any help will be appreciated,
Thanks

Reply With Quote
  #2  
Old December 22nd, 2003, 07:17 AM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,005 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 11 h 33 m 53 sec
Reputation Power: 67
I did not test it, but shouldn't it be:
Code:
CREATE TRIGGER handleReciprocity
AFTER INSERT ON gift
REFERENCING
      NEW ROW AS nt
FOR EACH ROW
      WHEN( ((SELECT reciprocity FROM family
             WHERE id = nt.receiver_id) = 'YES') AND
             NOT EXISTS ( SELECT * FROM gift
                          WHERE (sender_id = nt.receiver_id AND
                                 receiver_id = nt.sender_id AND
                                 occasion = nt.occasion AND
                                 reciprocal = 'YES')))
BEGIN
      INSERT INTO gift
             VALUES(nt.receiver_id, nt.sender_id, nt.occasion, nt.presentType, 'YES', nt.orderId + 1);
END;
/

Reply With Quote
  #3  
Old December 22nd, 2003, 02:35 PM
Vortrex Vortrex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 Vortrex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Uhmm i was missing the / at the end of the script. I had no idea you have to use it.
At least i'm getting error messages now
Do you have to use a / at the end of every script? or just scripts containing triggers?

Thanks for the help

Last edited by Vortrex : December 22nd, 2003 at 02:42 PM.

Reply With Quote
  #4  
Old December 22nd, 2003, 05:49 PM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,005 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 11 h 33 m 53 sec
Reputation Power: 67
Especially in scripts with triggers!

Your trigger will eventually have more then one statement, and thus more then one ; in it.
How should the parser know which ; terminates the triger and which ; just terminates a statement

Reply With Quote
  #5  
Old December 23rd, 2003, 04:56 AM
Vortrex Vortrex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 Vortrex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks a lot!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > newbie Trigger problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway