2d array issues - Mailing list pgsql-general

From John Gant
Subject 2d array issues
Date
Msg-id f9f875540702282153j65965dcdxa37a6d6c15a9a35d@mail.gmail.com
Whole thread Raw
List pgsql-general
Hello,
Can anyone tell me why the function below is breaking at the second assignment? I am trying to set values for columns 1 and 2 for row 1. The compilation and error are below the function definition. Thanks in advance.

  1. CREATE OR REPLACE FUNCTION test() returns void AS $$
  2. declare
  3. matrix numeric [] [];
  4. cnt numeric := 1;
  5. begin
  6. matrix[cnt] [1] := 3;
  7. raise notice '%', matrix[cnt ][1];
  8. matrix[cnt] [2] := 4;
  9. raise notice '%', matrix[cnt ][2];
  10. end;
  11. $$ LANGUAGE plpgsql;
  12.  
  13. error...
  14. stocks=# \i test.sql
  15. CREATE FUNCTION
  16. stocks=# select test();
  17. NOTICE: 3
  18. ERROR: invalid array subscripts
  19. CONTEXT: PL/pgSQL FUNCTION "test" line 7 at assignment

pgsql-general by date:

Previous
From: "Saqib Awan"
Date:
Subject: 8.1.8 Installer Fails on Win2k Server
Next
From: "Andrew T. Robinson"
Date:
Subject: Constructors for dates, times, and timestamps