Guest User

Untitled

a guest
Jul 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. -- Return codes:
  2. -- 0 = ok
  3. -- 1 = excess already exists, not added
  4. CREATE OR REPLACE FUNCTION LUM_MgtLiabConfig_sp_EditLimit
  5. (
  6. Mode character varying,
  7. LmitID int,
  8. ClassOfBusID int,
  9. Lmit bigint,
  10. Multiplr decimal(9,3),
  11. UWMCnfigID int
  12. )
  13. RETURNS INT
  14. AS
  15. $$
  16. BEGIN
  17. IF Mode = 'delete'
  18. THEN
  19.  
  20. DELETE FROM
  21. LUM_MgtLiabConfig_tblLimit
  22. WHERE
  23. LimitID = LmitID AND
  24. UWMConfigID = UWMCnfigID;
  25.  
  26. RETURN;
  27.  
  28. END IF;
  29.  
  30. IF Mode = 'update'
  31.  
  32.  
  33. -- First check that there isn't already a record for this Excess/Product EXCEPT for the one being edited!
  34. IF (SELECT COUNT(*)
  35. FROM LUM_MgtLiabConfig_tblLimit
  36. WHERE Limit = Lmit AND ClassOfBusinessID = ClassOfBusID AND LimitID <> LmitID AND UWMConfigID = UWMCnfigID;)
  37. <> 0
  38. RETURN 1;
  39. END IF;
  40. UPDATE LUM_MgtLiabConfig_tblLimit
  41. SET
  42. "limit' = Lmit,
  43. Multiplier = Multiplr
  44.  
  45. WHERE
  46. LimitID = LmitID AND
  47. UWMConfigID = UWMCnfigID;
  48.  
  49. RETURN;
  50.  
  51. END IF;
  52.  
  53. IF Mode = 'add'
  54.  
  55.  
  56. -- First check that there isn't already a record for this Excess/Product
  57. IF (SELECT COUNT(*)
  58. FROM LUM_MgtLiabConfig_tblLimit
  59. WHERE Limit = Lmit AND ClassOfBusinessID = ClassOfBusID AND UWMConfigID = UWMCnfigID;)
  60. <> 0
  61. RETURN 1;
  62. END IF;
  63.  
  64. INSERT INTO LUM_MgtLiabConfig_tblLimit
  65. (ClassOfBusinessID,
  66. UWMConfigID,
  67. Limit,
  68. Multiplier)
  69. VALUES
  70. (ClassOfBusID,
  71. UWMCnfigID,
  72. Lmit,
  73. Multiplr);
  74.  
  75. RETURN;
  76. END IF;
  77.  
  78. END;
  79. $$Language 'plpgsql';
Add Comment
Please, Sign In to add comment