PL/SQL (MOSC)

MOSC Banner

Synchronize column with max from another table

edited May 11, 2015 10:01AM in PL/SQL (MOSC) 13 commentsAnswered

I would like to synchronize column last_corr_date from table A with the max value of table NEGOTIATION per emp_code and app_counter

Tables

A                                                                                        NEGOTIATION

-----------------------------------                                                -----------------------------------

emp_code           number                                                  emp_code           number                                                 

app_counter        number                                                  app_counter        number    

last_corr_date     date                                                       entered_date       date

CREATE OR REPLACE TRIGGER TRIG_1 BEFORE

INSERT

OR UPDATE

OR DELETE OF "ENTERED_DATE" ON "NEGOTIATION" REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN

update a

set last_corr_date=(select max(negotiation.entered_date) from negotiation where negotiation.emp_code=:old.emp_code and negotiation.app_counter=:old.app_counter)

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center