Advertisement
aadddrr

f_get_flag_warranty_for_so_id

Nov 9th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Adrian, Nov 09, 2017
  3.  * Untuk mendapatkan flag warranty so item
  4.  */
  5.  
  6. CREATE OR REPLACE FUNCTION f_get_flag_warranty_for_so_id(bigint)
  7.   RETURNS numeric AS
  8. $BODY$
  9. DECLARE
  10.     pMasterId               alias for $1; --so_item_id
  11.  
  12.     vResult                 numeric;
  13.    
  14. BEGIN
  15.  
  16.     vResult := 0;
  17.    
  18.     WITH tt_count_so_warranty_item AS (
  19.         SELECT COUNT(*) AS warranty_count
  20.         FROM sl_so_warranty_item
  21.         WHERE so_item_id = pMasterId
  22.     )
  23.     SELECT
  24.         CASE WHEN warranty_count = 0 THEN
  25.             'N'
  26.         ELSE
  27.             'Y'
  28.         END IF
  29.     INTO vResult
  30.     FROM tt_count_so_warranty_item;
  31.    
  32.     return vResult;
  33. END;
  34. $BODY$
  35.   LANGUAGE plpgsql VOLATILE
  36.   COST 100;
  37.   /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement