Oracle To_char Subquery In Trigger
I have a table (Meeting) with date type attribute (MeetDate) and another varchar2 type attribute (WorkWeek). I'm trying to do an After trigger to fill in the WorkWeek field based o
Solution 1:
You just want a trigger to change the value of a column before it gets inserted - and it's on the same row, so you don't need an UPDATE:
Createor Replace Trigger Update_WorkWeek
BEFORE InsertOn Meeting
ForEachRowBegin
:new.WorkWeek := to_char(:new.MeetDate, 'YYYY IW');
End;
/show Errors;
You might want the column kept up-to-date if the MeetDate is changed, i.e.:
Createor Replace Trigger Update_WorkWeek
BEFORE InsertORUpdateOF MeetDate
On Meeting
ForEachRowBegin
:new.WorkWeek := to_char(:new.MeetDate, 'YYYY IW');
End;
/show Errors;
Post a Comment for "Oracle To_char Subquery In Trigger"