-- レーベル名からレーベルコード取得 失敗時は0
-- DROP FUNCTION s_get_labelcd(character varying); -- 旧SP
CREATE OR REPLACE FUNCTION s_get_labelcd(_makercd integer, _labelnm varchar) RETURNS integer AS
$BODY$
DECLARE
    labelc integer;
BEGIN

    SELECT labelcd INTO labelc FROM t_label WHERE makercd = _makercd AND s_get_nocase_text(labelnm) LIKE s_get_nocase_text(_labelnm) AND delflg = FALSE;
    IF NOT FOUND THEN
        RETURN 0;
    ELSE
        RETURN labelc;
    END IF;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

