0

Trying to append an array to an array does not seem to work.

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$;

Seem to get the following error

ERROR:  function array_append(bigint[], bigint[]) does not exist
LINE 1: SELECT array_append(CRNS,TMPS)
           ^

1 Answer 1

1

The function array_append() appends an element to an array. You should concatanate two arrays with the operator ||.

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$;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.