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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After Update Trigger

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,529
US
I have a table PSLET_INFORMATION with the field PSLET_RECORD_LAST_UPDATED (Date)
I would like to set this field to SYSDATE whenever there is any Update to any record(s) in that table.

So I've tried a trigger:

Code:
create trigger PSLET_INFORMATION_T 
AFTER UPDATE
ON PSLET_INFORMATION
FOR EACH ROW[highlight]
begin[/highlight]
    :new.PSLET_RECORD_LAST_UPDATED := SYSDATE;
end PSLET_INFORMATION_T;
/

I get an error PLS-00103:
Encountered the symbol 'end-of-file' when expecting one of the following:
(begin case declare exit for ...)

Any ideas of how this simple trigger should look like?

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Pretty much one word difference:

Code:
create or replace trigger PSLET_INFORMATION_T [highlight]
BEFORE [/highlight]UPDATE
ON PSLET_INFORMATION
FOR EACH ROW
begin
    :new.PSLET_RECORD_LAST_UPDATED := SYSDATE;
end PSLET_INFORMATION_T;
/

Looks like you can change data in the table with the trigger using BEFORE update.
AFTER update will change the data in other tables.

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Actually you can change other tables data in either a before or after trigger. However you can only update data on the table that the trigger is on using a before trigger.

Bill
Lead Application Developer
New York State, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top