Karen,
Is this a BEFORE DELETE or AFTER DELETE Trigger?
Conflicts may arise if it is define as a BEFORE DELETE Trigger as to the best 
of my knowledge the record action is still pending at that point.

Your 2nd and 3rd selects are accessing "OppActivity" table which is being held 
by the internal read only cursor used to define the trigger  action.
I believe that an AFTER DELETE Trigger will not have the conflicts.


Jim Bentley,
American Celiac Society
1-504-737-3293


________________________________
 From: "[email protected]" <[email protected]>
To: RBASE-L Mailing List <[email protected]> 
Sent: Monday, July 30, 2012 8:56 AM
Subject: [RBASE-L] - Struggling with SP code
 

Working with 9.5.  I have a table called OppActivity, with a PK autonumber 
field OppActivityID.  There is a FK field OppID that points to the master table 
Opportunity that has a PK OppID.

What I need to do:  I know it breaks every relational rule but for performance 
purpose we want to update 4 fields in Opportunity to show the latest values 
from OppActivity.   I have a SP/Trigger working perfectly when I insert and 
delete a row into OppActivity to get the latest row and put in Opportunity.  My 
problem is with the Delete SP.  Doesn't seem to work the same way as 7.6 did...

I want the trigger to work both from a form but also from a data browser at the 
r> prompt so I don't want to rely on there being pre-defined variables to 
indicate which OppID I'm working on.

Here's the code I'm using (edited down to show only 1 of the 4 fields I want to 
update), but I'm getting all kinds of "resource conflict" and other errors, 
strangely on the "select (max)" line.  I'm working locally, multi off.  I have 
this as a "before delete" trigger.  Any suggestions?


SET VAR pvOppID INT = NULL, pvOppActID INT = NULL, pvADate DATE = NULL

SELECT OppActivityID, OppID INTO pvOppActID, pvOppID FROM OppActivity WHERE 
CURRENT OF SYS_OLD
SELECT (MAX(OppActivityID)) INTO pvOppActivityID FROM OppActivity +
  WHERE OppID = .pvOppID AND OppActivityID <> .pvOppActID
SELECT ActivityDate INTO pvADate +
  FROM OppActivity WHERE OppActivityID = .pvOppActivityID
UPDATE opportunity SET +
  CurrActivityDate = .pvADate +
  WHERE OppID = .pvOppID


Thanks for looking!

Karen

Reply via email to