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

Data Cleansing Trigger

Status
Not open for further replies.

TimboA

MIS
Jul 12, 2001
38
0
0
GB
I currently have a date field in a table that is being written to from an Access Front End. However, sometimes (and I haven't yet found out why!!) the date is written from the access client machines in DD/MM/YY format, but other times it's in MM/DD/YY format.

I need to create a trigger that will capture those records that are being inserted as MM/DD/YY and switch them back to DD/MM/YY. I've tried the following, but get a mutating table error :-

create or replace trigger tg_completed
AFTER INSERT on t_accepted
for each row

DECLARE

v_UserID VARCHAR2(8);
v_Updated DATE;

BEGIN

IF :new.accepted_id is not null then

update T_ACCEPTED
set CLOSE_DATE = trunc(sysdate)
where accepted_id = :new.accepted_id
and request_id = :new.request_id;

END IF;

END;

Anyone know of a way around this.....
 
No, it's a lot simpler than that. You just need to do:

:new.close_date := trunc(sysdate);
 
Thanks Dagon, I think my brain was having a relapse...sledge hammer and nut and all that.
 
Thanks Dagon, I think my brain was having a relapse...sledge hammer and nut and all that.

PS - I had to change it to a BEFORE Insert to get it to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top