Home » SQL & PL/SQL » SQL & PL/SQL » something different with the trigger
something different with the trigger [message #687] Tue, 26 February 2002 10:28 Go to next message
Rock
Messages: 18
Registered: February 2002
Junior Member
Okay so I have the following trigger rhat works fine within a procedure and have an insert but how about if I want to create a view.
So instead of the "Insert into one values(Var,0)"..do something more complex but dynamic...

Create or replace trigger change_trig
after insert or update or delete on my_table for each row
Declare
Var Number;
Begin
Var := 0;
"Insert into one values(Var,0)"
Exception
When others then
-- Consider logging the error and then
re-raise raise;
End Change_trig;
Re: something different with the trigger [message #689 is a reply to message #687] Tue, 26 February 2002 16:41 Go to previous message
seng
Messages: 191
Registered: February 2002
Senior Member
First, here is some information about VIEW. Logicaly, VIEW is similar to TABLE, but VIEW is only a DML and without using any space for data as TABLE. When a user is selected field from VIEW, Oracle Server will execute DML (VIEW) and fatch the data from combined tables. It is looked like table.

In your question, you can use VIEW to do these DML action like INSERT,DELETE,UPDATE and SELECT inside TRIGGER. But,you need to concern about the constraint on TABLE(Combination of VIEW).
E.g primary, foreign, and other constraints.

The failure to fullfill the TABLE's (Combination of VIEW)constraint will cause the whole rollback. This include data on trigger's table. So some of article has mention that VIEW is not suitable for INSERT, DELETE and UPDATE action, if the user is not able to prevent the constraint error to happen.

You can use view if you are ready known the data logic in your database. Hope, this will help you. Thanks
Previous Topic: function based index?
Next Topic: Re: difference : primary key and unique not null
Goto Forum:
  


Current Time: Thu Mar 28 07:17:06 CDT 2024