Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

trigger old/new values

DGSFeb 18 2010 — edited Feb 18 2010
I have some STAMP columns in a table that I would like to populate with a trigger so that they are consistently populated.

On insert
STAMP_ADD_DATE
STAMP_ADDED_BY

On update
STAMP_UPDATE_DATE
STAMP_UPDATED BY

My problem is occuring on the update portion. Here is the text:
IF :new.stamp_updated_by IS NULL THEN
:new.stamp_updated_by := sys_context('USERENV', 'OS_USER');
END IF;
:new.stamp_update_date := d_today;

9 out of 10 times our .NET front end will pass in a value for :NEW.STAMP_UPDATED_BY to the procedure. That works great.

When I perform an update from SQL*Plus and omit the column from the update statement, it is reusing the :OLD.STAMP_UPDATED_BY value from the original record.

I would have expected it to realize that I have not referenced that column and fallen into the NULL condition in the trigger. Like a column default value..

Is there a way, without specifying the column name in the update statement to get this column to fall into the NULL condition if it is not specified in the update statement?


Thanks,
ds
This post has been answered by MichaelS on Feb 18 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2010
Added on Feb 18 2010
14 comments
1,766 views