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:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old April 13th, 2004, 06:02 AM
gary noble gary noble is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 6 gary noble User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Trigger problems

I have a problem with getting this trigger to compile. It involves a book database, with four tables. customer, book, supplier and telephone_purchase. The trigger is meant to increment the number of sales of a book whenever it is purchased but whatever i do i just can't get it to work.


CREATE OR REPLACE TRIGGER increase_book_total_no_sold
BEFORE DELETE or INSERT or UPDATE
ON book
FOR EACH ROW
BEGIN
if UPDATING then
UPDATE book
SET total_no_sold = :new.total_no_sold
WHERE book_isbn = ld.book_isbn;
end if;
if DELETING then
DELETE FROM book
WHERE book_isbn = ld.book_isbn;
end if;
if INSERTING then
INSERT INTO book
VALUES ( :new.book_isbn
,:new.total_no_sold

);
end if;
end;

hope someone can help me

Reply With Quote
  #2  
Old April 13th, 2004, 06:25 AM
jimliew jimliew is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 jimliew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it's likely that the table book has more than two columns so you need to provide values for all columns or change your insert statement to:

INSERT INTO book (book_isbn,total_no_sold)
VALUES ( :new.book_isbn
,:new.total_no_sold

Reply With Quote
  #3  
Old April 14th, 2004, 11:08 AM
gary noble gary noble is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 6 gary noble User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, but how do i test if the trigger works. It compiles ok but how do i test it?

Reply With Quote
  #4  
Old April 14th, 2004, 02:02 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
By playing (insert,delete,update) with BOOK table.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Trigger problems


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 2 hosted by Hostway