Re: Arrays

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ymir <ymir(at)wolfheart(dot)ro>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Arrays
Date: 2002-03-13 18:50:14
Message-ID: 9904.1016045414@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ymir <ymir(at)wolfheart(dot)ro> writes:
> I'm trying to use a bidimensional array and I'm having the following
> problem:

> students=# UPDATE years SET y_grade[1] = '{2,3,4,5,6,7}';
> ERROR: pg_atoi: error in "{2,3,4,5,6,7}": can't parse "{2,3,4,5,6,7}"

Not the right subscripts for an array slice. Try it this way:

regression=# create table years(y_grade int[]);
CREATE
regression=# insert into years values('{{1,2,3,4,5,6},{11,22,33,44,55,66}}');
INSERT 164022 1
regression=# select * from years;
y_grade
-------------------------------------
{{1,2,3,4,5,6},{11,22,33,44,55,66}}
(1 row)

regression=# update years set y_grade[1][1:6] = '{2,3,4,5,6,7}';
UPDATE 1
regression=# select * from years;
y_grade
-------------------------------------
{{2,3,4,5,6,7},{11,22,33,44,55,66}}
(1 row)

> I've declared y_grade as a bidimensional array (y_grade smallint[][]), but
> still, I get this when I describe the table:

The declaration of the table just says that the column is an array of
int; the number of dimensions is not really constrained, any more than
the array size is.

regards, tom lane

In response to

  • Arrays at 2002-03-13 12:28:19 from Ymir

Browse pgsql-general by date

  From Date Subject
Next Message Joel Rodrigues 2002-03-13 18:53:40 Re: spanish characters in postgresql
Previous Message Doug McNaught 2002-03-13 18:48:37 Re: Query planner problem