Subject | Calling Stored Procedure from Trigger |
---|---|
Author | bzwirs |
Post date | 2009-08-13T20:55:36Z |
Hi,
I have a Trigger as follows
CREATE TRIGGER BI_SALES_PER_WEEK FOR SALES ACTIVE AFTER INSERT OR UPDATE POSITION 2 AS
declare variable AVG_PERWEEK NUMERIC(15,2);
BEGIN
select AVG_WEEKSALES from GET_WEEKLY_SALES(NEW.MACHID,NEW.SITEID)
into :AVG_PERWEEK;
UPDATE MACHSITE
SET SALESPERWEEK = :AVG_PERWEEK
WHERE MACHID = NEW.MACHID AND
SITEID = NEW.SITEID;
END
I want to call a Stored Procedure named GET_WEEKLY_SALES which returns the AVG_WEEKSALES value. Is this the correct way to call a Stored Procedure from within a Trigger? I have tested the Stored Procedure in Database Workbench and it gives the correct value, yet the Trigger comes up with Null.
thanks in advance
Bill Zwirs
I have a Trigger as follows
CREATE TRIGGER BI_SALES_PER_WEEK FOR SALES ACTIVE AFTER INSERT OR UPDATE POSITION 2 AS
declare variable AVG_PERWEEK NUMERIC(15,2);
BEGIN
select AVG_WEEKSALES from GET_WEEKLY_SALES(NEW.MACHID,NEW.SITEID)
into :AVG_PERWEEK;
UPDATE MACHSITE
SET SALESPERWEEK = :AVG_PERWEEK
WHERE MACHID = NEW.MACHID AND
SITEID = NEW.SITEID;
END
I want to call a Stored Procedure named GET_WEEKLY_SALES which returns the AVG_WEEKSALES value. Is this the correct way to call a Stored Procedure from within a Trigger? I have tested the Stored Procedure in Database Workbench and it gives the correct value, yet the Trigger comes up with Null.
thanks in advance
Bill Zwirs