window.repositoryObject = {"parameters_custom_fields":[],"object_id":"f376","name":"FN_GET_FREEGIFT_GOODS_YN","subtype":"FUNCTION","is_user_defined":false,"description":null,"summary":[{"field":"Documentation","value":{"_type":"link","name":"style24@172.30.90.100","id":"d10"}},{"field":"Schema","value":""},{"field":"Name","value":"FN_GET_FREEGIFT_GOODS_YN"},{"field":"Type","value":"Function"}],"script":"BEGIN\r\n    DECLARE O_RETURN_VAL CHAR(1);\r\n\r\n    SELECT CASE\r\n               WHEN COUNT(A.GOODS_CD) > 0 THEN 'Y'\r\n               ELSE 'N' END\r\n    INTO O_RETURN_VAL\r\n    FROM (SELECT G.GOODS_CD\r\n          FROM TB_FREEGIFT F\r\n                   INNER JOIN TB_FREEGIFT_SECTION FS\r\n                              ON F.FREEGIFT_SQ = FS.FREEGIFT_SQ\r\n                   INNER JOIN TB_FREEGIFT_GOODS FGA\r\n                              ON F.FREEGIFT_SQ = FGA.FREEGIFT_SQ\r\n                                  AND FGA.GOODS_GB = 'G800_20'\r\n                                  AND FGA.TARGET_GB = 'G260_10'\r\n                   INNER JOIN TB_GOODS G\r\n                              ON FGA.TARGET_VAL = G.GOODS_CD\r\n                   LEFT OUTER JOIN TB_FREEGIFT_GOODS NOT_APPLY\r\n                                   ON F.FREEGIFT_SQ = NOT_APPLY.FREEGIFT_SQ\r\n                                       AND G.GOODS_CD = NOT_APPLY.TARGET_VAL\r\n                                       AND NOT_APPLY.GOODS_GB = 'G800_30'\r\n                                       AND NOT_APPLY.TARGET_GB = 'G260_10'\r\n          WHERE NOT_APPLY.TARGET_VAL IS NULL\r\n            AND F.DEL_YN = 'N'\r\n            AND FS.DEL_YN = 'N'\r\n            AND FGA.DEL_YN = 'N'\r\n            AND NOW() BETWEEN F.FREEGIFT_STDT AND F.FREEGIFT_EDDT\r\n            AND F.SELF_YN = 'Y'\r\n            AND F.FREEGIFT_STAT = 'G232_11'\r\n            AND G.GOODS_CD = I_GOODS_CD\r\n          UNION ALL\r\n          SELECT G.GOODS_CD\r\n          FROM TB_FREEGIFT F\r\n                   INNER JOIN TB_FREEGIFT_SECTION FS\r\n                              ON F.FREEGIFT_SQ = FS.FREEGIFT_SQ\r\n                   INNER JOIN TB_FREEGIFT_GOODS_APPLY BRAND_FGA\r\n                              ON F.FREEGIFT_SQ = BRAND_FGA.FREEGIFT_SQ\r\n                                  AND BRAND_FGA.TARGET_GB = 'G260_12' -- 브랜드\r\n                   INNER JOIN TB_FREEGIFT_GOODS_APPLY COMPANY_FGA\r\n                              ON F.FREEGIFT_SQ = COMPANY_FGA.FREEGIFT_SQ\r\n                                  AND COMPANY_FGA.TARGET_GB = 'G260_13' -- 업체\r\n                   INNER JOIN TB_GOODS G\r\n                              ON BRAND_FGA.TARGET_VAL = G.BRAND_CD\r\n                                  AND COMPANY_FGA.TARGET_VAL = G.SUPPLY_COMP_CD\r\n                   LEFT OUTER JOIN TB_FREEGIFT_GOODS NOT_APPLY\r\n                                   ON F.FREEGIFT_SQ = NOT_APPLY.FREEGIFT_SQ\r\n                                       AND G.GOODS_CD = NOT_APPLY.TARGET_VAL\r\n                                       AND NOT_APPLY.GOODS_GB = 'G800_30'\r\n          WHERE NOT_APPLY.TARGET_VAL IS NULL\r\n            AND F.DEL_YN = 'N'\r\n            AND FS.DEL_YN = 'N'\r\n            AND NOW() BETWEEN F.FREEGIFT_STDT AND F.FREEGIFT_EDDT\r\n            AND F.SELF_YN = 'Y'\r\n            AND F.FREEGIFT_STAT = 'G232_11'\r\n            AND G.GOODS_CD = I_GOODS_CD) A;\r\n\r\n    RETURN O_RETURN_VAL;\r\nEND","parameters":[{"name":"Returns","description":null,"mode":"OUT","data_type":"char(1)","custom_fields":{}},{"name":"I_GOODS_CD","description":null,"mode":"IN","data_type":"varchar(20)","custom_fields":{}}],"dependencies":null,"imported_at":"2021-11-11 16:37"};