|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Ok I got a question concerning triggers in PL/SQL.
I'm able to make a trigger that inserts, updates and deletes in table2 when I do an insert, update or delete on table1. My problem is: Let's say I have a table with 3 rows and when I insert, update or delete on that table I want another table that include one of those rows to be updated too. I've only managed to "copy" it over if the tables are exactly the same. When I try to get 1 field over I get a "not enough values" message. What can I do to get around the fact that I send less attributes than there is in the table I want to update? Here is the script I'm trying to use. CREATE OR REPLACE TRIGGER Bruker_Insert_Update_Delete BEFORE INSERT OR UPDATE OR DELETE ON Bruker FOR EACH ROW BEGIN IF UPDATING THEN UPDATE Kopling SET BrukerID = :new.BrukerID; END IF; IF INSERTING THEN INSERT INTO Kopling VALUES( :new.BrukerID ); END IF; IF DELETING THEN DELETE FROM Kopling WHERE BrukerID = ld.BrukerID;END IF; END; / |
|
#2
|
|||
|
|||
|
Code:
IF INSERTING THEN INSERT INTO Kopling (columnName) VALUES( :new.BrukerID ); END IF; |
|
#3
|
|||
|
|||
|
Thanks alot
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Triggers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|