Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Before Update

Status
Not open for further replies.

roche786

Programmer
Sep 5, 2002
24
US
Hi,

I am trying to write a before update trigger , which should before updating the current table should take all the old values and insert it into an audit table.

I wrote this but its giving compilation error please let me know where I am going wrong.


create or replace trigger tbl_update
before update on tbl_update
for each row

begin

insert into TBL_update_AUDIT(a,b,c)

values

:)old.a,:eek:ld.b,'u');

end;

Kindly advice.

Thanks
 
You must have unique object names within a schema. If your table is called tbl_update, then you must use a different unique name for the trigger.

create or replace trigger tbl_update_t1
before update on tbl_update
for each row

begin

insert into TBL_update_AUDIT(a,b,c)
values
:)old.a,:eek:ld.b,'u');

end;

Bill
Oracle DBA/Developer
New York State, USA
 
Sorry I mistyped the name it is unique and called tbl_update_trg .

It still gives compilation error.

The trigger should move the row being updated on to the audit table and should update the values in the current table.

Thanks for the help.
 
Could you post the error?

Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
Author and Sole Proprietor of: Emu Products Plus
 
Does tbl_update have a column "a"?

Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
Author and Sole Proprietor of: Emu Products Plus
 
Code:
CREATE OR REPLACE TRIGGER t_t2_audit
AFTER UPDATE 
ON t2 
REFERENCING NEW AS n OLD AS o 
FOR EACH ROW

BEGIN
   INSERT INTO changes
   VALUES (:n.x, :o.x, user); 
END t_t2_audit;
/

UPDATE t2
SET x = 1;
COMMIT;

[bandito] [blue]DBomrrsm[/blue] [bandito]

[blue]Software code, like laws and sausages, should never be examined in production[/blue][black] - [/black][purple]Edward Tenner[/purple]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top