add two table triggers to table WorkOrder, one after enter trigger and a delete trigger

the triggers will be something like ...

SELECT WorkLocation INTO xWorkLocation +
  FROM WorkOrder WHERE CURRENT OF SYS_NEW

update Location set LocCount=(count(*)) +
from Location T1, WorkOrder  t2, +
where t1.LocName=.xWorkLocation  and t1.LocName=t2.WorkLocation
clear var xWorkLocation
return 0

or
SELECT WorkLocation INTO xWorkLocation +
  FROM WorkOrder WHERE CURRENT OF SYS_NEW

set VAR xLocCount int = '0'

select count(*) into xLocCount from WorkOrder where WorkLocation =.xWorkLocation

update Location set LocCount=(.xLocCount ) +
where LocName=.xWorkLocation

clear var x%
return 0

you can play around and for the delete trig subtract 1 from the count. I use table triggers for doing this sort of update alot and have had good success.

Have a Fabulous Day!
Rachael M.
Freelance Developer
www.DragonflyDevelopmentMN.com
----- Original Message ----- From: "javier valencia" <[EMAIL PROTECTED]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Friday, January 18, 2008 10:44 AM
Subject: [RBASE-L] - Brain freeze...


I am having one of those days when my brain is just not quite working;
probably anticipation for tomorrows KU-MU BBall game...Go Jayhawks...

I have a table that has unique locations (LocName) and a second table that
has work orders with a location column (WorkLocation)
For each location in the first table I want to upgrade the count with the
number of occurrences in the second table.

Table Location
LocName        LocCount
==================
LocA                  2
LocB                  3
LocC                  0

Table WorkOrder
WoNo              WorkLocation
==================
1                       LocA
2                       LocB
3                       LocB
4                       LocA
5                       LocB

I need to update table Location with the count of values in table WorkOrder.
I believe there should be an UPDATE statement that does this globally, but
somehow, anything I have tried either gives me a syntax error or does not
work...Any ideas??? TIA.

Javier,

Javier Valencia, PE
President
Valencia Technology Group, L.L.C.
14315 S. Twilight Ln., Suite #101
Phone: 913-829-0888
Fax: 913-649-2904
Cell: 913-915-3137


================================================
Attention:
The information contained in this message and or attachments is intended
only for the person or entity to which it is addressed and may contain
confidential and/or privileged material.  Any review, retransmission,
dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient
is prohibited. If you received this in error, please contact the sender and
delete the material from all system and destroy all copies.
======================================================


Reply via email to