xbox360dp
asked on
Help with AFTER INSERT trigger
Gurus,
I wrote a before insert trigger that isn't working.
create or replace
TRIGGER katvf7c_to_katimpc before
insert on KAT for each row
begin
:new.KATIMPC := :new.KATPF7C;
end;
What is the best way to convert this to an AFTER INSERT trigger as I can use the :new option? Thanks in advance!
I wrote a before insert trigger that isn't working.
create or replace
TRIGGER katvf7c_to_katimpc before
insert on KAT for each row
begin
:new.KATIMPC := :new.KATPF7C;
end;
What is the best way to convert this to an AFTER INSERT trigger as I can use the :new option? Thanks in advance!
Instead of changing it, fix what isn't working.
This works for me:
This works for me:
drop table tab1 purge;
create table tab1(col1 char(1), col2 char(1));
create or replace trigger tab1_trig
before insert on tab1
for each row
begin
:new.col2 := :new.col1;
end;
/
show errors
insert into tab1(col1) values('a');
commit;
select * from tab1;
ASKER
It's something funky through our application. If I insert the record directly through the database the trigger works fine.
Inserting into a table with a trigger and not having the trigger fire is not a feature of a 'funky application'. It is a pretty huge bug/hole in the database.
The trigger as written will work. Something isn't right. I would dig deeper.
The trigger as written will work. Something isn't right. I would dig deeper.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you have 2 columns that must always be equal, you might want to consider simply dropping the KATIMPC column and then recreating it as a virtual column.
Of course that will mean rearranging the order of columns in your table, so it might not be feasible.
Another option but a bit more cumbersome: change the name of the table and create a view with the table's original name. This will let you drop the physical column but recreate the logical column in its original position within the table.
Of course that will mean rearranging the order of columns in your table, so it might not be feasible.
Another option but a bit more cumbersome: change the name of the table and create a view with the table's original name. This will let you drop the physical column but recreate the logical column in its original position within the table.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for xbox360dp's comment #a40328681
for the following reason:
This worked for me.
Accepted answer: 0 points for xbox360dp's comment #a40328681
for the following reason:
This worked for me.
Shouldn't a split be in order since you changed your trigger based on my comment about updates?
your syntax is valid, what isn't working about it?
what are you trying to do?