-- シリーズ名からシリーズコード取得 失敗時は0
-- DROP FUNCTION s_get_seriescd(character varying); -- 旧SP
CREATE OR REPLACE FUNCTION s_get_seriescd(_makercd integer, _seriesnm varchar) RETURNS integer AS
$BODY$
DECLARE
    seriesc integer;
BEGIN

    SELECT seriescd INTO seriesc FROM t_series WHERE makercd = _makercd AND s_get_nocase_text(seriesnm) LIKE s_get_nocase_text(_seriesnm) AND delflg = FALSE;
    IF NOT FOUND THEN
        RETURN 0;
    ELSE
        RETURN seriesc;
    END IF;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
