Subject | Stored Proc Question |
---|---|
Author | Robert F. Tulloch |
Post date | 2001-10-03T05:07:46Z |
Hi:
Since we can't use an If this then that..else etc etc
Can you do multiple updates on same field depending on value thusly??
SET TERM ## ;
CREATE PROCEDURE UPDATE (PARAM1 INTEGER, DATE1 DATE, YEAR1 INTEGER,
PARAM2 INTEGER, PARAM3 INTEGER, PARAM4 INTEGER)
AS
DECLARE VARIABLE RdID INTEGER;
BEGIN
FOR SELECT ID
FROM TABLE1
WHERE STATUS = 'ACTIVE'
INTO :RdID
DO
UPDATE TABLE2 T2
SET T2.F1 = (PARAM1 WHERE (T2.F1 = PARAM2)),
T2.F2 = (PARAM3 WHERE (T2.F2 = PARAM4))
WHERE T2.ID = :RdID AND T2.DUESDATE >= DATE1 AND EXTRACT(year FROM
T2.YEARM2 >= YEAR1);
END ##
SET TERM ; ##
Thanks.
Best regards
Since we can't use an If this then that..else etc etc
Can you do multiple updates on same field depending on value thusly??
SET TERM ## ;
CREATE PROCEDURE UPDATE (PARAM1 INTEGER, DATE1 DATE, YEAR1 INTEGER,
PARAM2 INTEGER, PARAM3 INTEGER, PARAM4 INTEGER)
AS
DECLARE VARIABLE RdID INTEGER;
BEGIN
FOR SELECT ID
FROM TABLE1
WHERE STATUS = 'ACTIVE'
INTO :RdID
DO
UPDATE TABLE2 T2
SET T2.F1 = (PARAM1 WHERE (T2.F1 = PARAM2)),
T2.F2 = (PARAM3 WHERE (T2.F2 = PARAM4))
WHERE T2.ID = :RdID AND T2.DUESDATE >= DATE1 AND EXTRACT(year FROM
T2.YEARM2 >= YEAR1);
END ##
SET TERM ; ##
Thanks.
Best regards