|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
thanks, but how do i test if the trigger works. It compiles ok but how do i test it?
|
|
#4
|
|||
|
|||
|
By playing (insert,delete,update) with BOOK table.
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Trigger problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|