CREATE OR REPLACE FUNCTION accpj.translatedtl(
  p_tblcode TEXT,
  p_dtlcod TEXT
)
RETURNS TEXT
LANGUAGE plpgsql
AS $func$
DECLARE
  resultName TEXT;
BEGIN
  SELECT dtlnam
  INTO resultName
  FROM accpj.dtlmst
  WHERE dtltblcod = p_tblcode
    AND dtlcod = p_dtlcod
  LIMIT 1;

  RETURN resultName;
END;
$func$;



--แบบ สองดัชนี SELECT public.translatedtl_multi(ARRAY['ACTCAT_INC','ACTCAT_EXP'], actcat) AS actcatnam;


CREATE OR REPLACE FUNCTION accpj.translatedtl_multi(
  p_tblcodes TEXT[],
  p_dtlcod TEXT
)
RETURNS TEXT
LANGUAGE sql
AS $func$
  SELECT dtlnam
  FROM accpj.dtlmst
  WHERE dtltblcod = ANY(p_tblcodes)
    AND dtlcod = p_dtlcod
  LIMIT 1;
$func$;

