尝试将数组附加到数组似乎不起作用。
DO
$do$
DECLARE
COUNTER INTEGER = 0;
CRNS bigint [];
TMPS bigint [];
BEGIN
WHILE COUNTER < 2 LOOP
TMPS := ARRAY(select plain_crn from call_records where timestamp=1467981702966);
array_append(CRNS,TMPS);
RAISE NOTICE '%',CRNS;
COUNTER := COUNTER + 1;
END LOOP;
END
$do$;
似乎收到以下错误
ERROR: function array_append(bigint[], bigint[]) does not exist
LINE 1: SELECT array_append(CRNS,TMPS)
^
答案 0 :(得分:1)
函数array_append()
将一个元素追加到数组中。您应该使用运算符||
连接两个数组。
DO
$do$
DECLARE
COUNTER INTEGER = 0;
CRNS bigint [];
BEGIN
WHILE COUNTER < 2 LOOP
CRNS := CRNS || ARRAY(select plain_crn from call_records where timestamp=1467981702966);
RAISE NOTICE '%',CRNS;
COUNTER := COUNTER + 1;
END LOOP;
END
$do$;