Postgresql问题-格式不正确的数组文字赋值时,数组值必须以“ {”开头或尺寸信息

时间:2018-10-31 03:43:29

标签: arrays

当我执行以下函数时,格式错误的数组文字-发生赋值错误时,数组值必须以“ {”开头或尺寸信息。

CREATE TYPE rec_emp AS(id numeric,
eseq_id numeric,
eid character varying(11),
h_dt timestamp(0) without time zone);

CREATE OR REPLACE FUNCTION p_tstfunc()
RETURNS void
AS
$BODY$
DECLARE
cur CURSOR FOR
SELECT id, eseq_id, eid, h_dt
FROM tst_emp WHERE st = 'N';

t_emp rec_emp [];
l_emp t_emp%TYPE;

l_eseq_id tst_emp.eseq_id%TYPE; 
l_h_dt tst_emp.h_dt%TYPE;  
cur$FOUND BOOLEAN DEFAULT false;
BEGIN

OPEN cur;
LOOP
FETCH cur INTO l_emp;
cur$FOUND := FOUND;

FOR i IN coalesce(array_lower(l_emp, 1), 1)..coalesce(array_upper      (l_emp,1),1) 
LOOP
BEGIN
  SELECT eseq_id, h_dt INTO l_eseq_id, l_h_dt
FROM tst_emp WHERE eid = l_emp[i].eid;

  l_emp[i] := (l_emp[i].id, l_eseq_id, l_emp[i].eid, l_emp[i].h_dt);
  l_emp[i] := (l_emp[i].id, l_emp[i].eseq_id, l_emp[i].eid, l_h_dt);

END;

EXIT WHEN (NOT cur$FOUND);
END LOOP;
END LOOP;

CLOSE cur_emp;          
END;
$BODY$
LANGUAGE  plpgsql;

能否让我知道如何解决此问题?问题指向l_emp [i]的分配。提前谢谢。

0 个答案:

没有答案