Skip to Main Content

QA trigger question

2884407Sep 16 2015 — edited Sep 16 2015

Hello

I have a trigger that adds the values of the username and the date to a table whenever the table gets INSERT/UPDATE statements. The trigger is as follows:

create or replace TRIGGER BUILDING_QA

BEFORE INSERT OR UPDATE ON BUILDING

FOR EACH ROW

DECLARE

  toDayDate DATE := sysdate();

BEGIN

  IF INSERTING THEN

     :new."ADDED_DATE" := toDayDate;

    :new."ADDED_BY" := USER;

  ELSE

     :new."ADDED_DATE" := :old."ADDED_DATE";

     :new."ADDED_BY" := :old."ADDED_BY";

  END IF;

  :new."CHANGED_BY" := USER;

  :new."CHANGED_DATE" := toDayDate;

END;

The BUILDING table looks like this:

BUILDING_IDBUILDING_NAMEADDED_DATEADDED_BYCHANGED_DATECHANGED_BY
1main_building2015-09-01

GEOCL

2015-09-16ROGMO
2secondary_building2013-08-25GEOCL2014-12-05GEOCL

I want to modify the trigger so that it adds the full name of the user to the buildings tables. The information of each user and its full name is located in another table on another schema. The table looks like the following:

IDUSERNAMEFULL_NAME
1GEOCLGeorge Clooney
2ROGMORoger Moore

The values of the full_name would be added to a new column in the BUILDING table (for example: ADDED_BY_FULL_NAME).

What is the best way to accomplish this?

Thanks in advanced

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Oct 14 2015
Added on Sep 16 2015
7 comments
159 views