View Single Post

   
  #4 (permalink)  
Old 02-27-2008, 07:11 AM
Art S. Kagel
 
Posts: n/a
Default Re: Newbie Insert Trigger question

rmcgorman@gmail.com wrote:
> I've been a Sybase DBA for a number of years. We now have a number of
> DB2 servers that
> I'm starting to work on. I've written many Sybase triggers but the DB2
> syntax is still unfamiliar. :-(
>
> I have a table AAA with columns "a" character(6), "b" character (30),
> and some others.
>
> I have a table LLL with columns "a" character(6), "b" character (30)
>
> When I insert into table AAA I do not know the value of column "b". I
> need my insert trigger to lookup the record in LLL where LLL.a = AAA.a,
> and insert the corresponding value from LLL.b into AAA.b
>
> TIA :-)
>

I agree with Phil and would add, if you need to always retrieve 'b' then
create an uninstantiated VIEW that includes the join from AAA to LLL on 'a'.
Problem solved without the insert overhead of the trigger or the
duplicated and possibility of column 'b' in AAA becoming out of synch with
LLL over time.

Art S. Kagel
Reply With Quote