Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Return codes:
- -- 0 = ok
- -- 1 = excess already exists, not added
- CREATE OR REPLACE FUNCTION LUM_MgtLiabConfig_sp_EditLimit
- (
- Mode character varying,
- LmitID int,
- ClassOfBusID int,
- Lmit bigint,
- Multiplr decimal(9,3),
- UWMCnfigID int
- )
- RETURNS INT
- AS
- $$
- BEGIN
- IF Mode = 'delete'
- THEN
- DELETE FROM
- LUM_MgtLiabConfig_tblLimit
- WHERE
- LimitID = LmitID AND
- UWMConfigID = UWMCnfigID;
- RETURN;
- END IF;
- IF Mode = 'update'
- -- First check that there isn't already a record for this Excess/Product EXCEPT for the one being edited!
- IF (SELECT COUNT(*)
- FROM LUM_MgtLiabConfig_tblLimit
- WHERE Limit = Lmit AND ClassOfBusinessID = ClassOfBusID AND LimitID <> LmitID AND UWMConfigID = UWMCnfigID;)
- <> 0
- RETURN 1;
- END IF;
- UPDATE LUM_MgtLiabConfig_tblLimit
- SET
- "limit' = Lmit,
- Multiplier = Multiplr
- WHERE
- LimitID = LmitID AND
- UWMConfigID = UWMCnfigID;
- RETURN;
- END IF;
- IF Mode = 'add'
- -- First check that there isn't already a record for this Excess/Product
- IF (SELECT COUNT(*)
- FROM LUM_MgtLiabConfig_tblLimit
- WHERE Limit = Lmit AND ClassOfBusinessID = ClassOfBusID AND UWMConfigID = UWMCnfigID;)
- <> 0
- RETURN 1;
- END IF;
- INSERT INTO LUM_MgtLiabConfig_tblLimit
- (ClassOfBusinessID,
- UWMConfigID,
- Limit,
- Multiplier)
- VALUES
- (ClassOfBusID,
- UWMCnfigID,
- Lmit,
- Multiplr);
- RETURN;
- END IF;
- END;
- $$Language 'plpgsql';
Add Comment
Please, Sign In to add comment