Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Simple trigger question

Author  Topic 

steamngn
Constraint Violating Yak Guru

306 Posts

Posted - 2005-02-08 : 11:42:55
Hi Gang,
I'm having a mental moment:
I need a simple trigger, but for some reason I can't seem to get it right:

create trigger updatelinefrt on po_ord_hdr
for insert,update
as update L
set L.freight=H.ord_misc_amt_1/(select max(L.seq_no)
from L where L.po_no=H.po_no)
from po_ord_hdr H
inner join po_ord_lin L
on l.po_no=h.po_no

This doesn't work. The ord_misc_amt_1 may also be NULL (more often than not), and I am not sure if we need to deal with that using COALESCE or not.
Andy

There's never enough time to type code right,
but always enough time for a hotfix...

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-02-08 : 15:46:29
Um...

What should it do?
What is it doing that you don't like?

HTH

=================================================================
Egotism is the anesthetic that dulls the pain of stupidity. -Frank William Leahy, football coach (1908-1973)
Go to Top of Page

steamngn
Constraint Violating Yak Guru

306 Posts

Posted - 2005-02-08 : 16:04:20
Hey Bustaz,
had a case of mycodiscrappus again...
As written it kept returning "unknown table l";
I changed the subquery from using alias' to using the table names.
That got it working.
Thanks!
Andy

There's never enough time to type code right,
but always enough time for a hotfix...
Go to Top of Page
   

- Advertisement -