trouble selecting from array

From: brian <brian(at)zijn-digital(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: trouble selecting from array
Date: 2008-03-27 23:38:29
Message-ID: 47EC2FF5.3080303@zijn-digital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Using 8.3

I have a table which has a column (tdr_tags) defined as integer[][]. The
table description shows the column as integer[]. I understand from the
docs that this is normal ("declaring number of dimensions or sizes in
CREATE TABLE is simply documentation").

If I select the column as tdr_tags I get:

{{161377},{32}}
{{206507},{39}}
{{232972,292831},{45,51}}
...

But, wanting just the 2nd inner array, if I try tdr_tags[2] I get NULL.
In fact, if use any array index at all I get back NULL. What I was
aiming to do was to select into a record in pl/pgsql and loop over the
content of the 2nd array.

Also, is there anything special required to load array data using COPY?
Does it require quoting? If so, is there any reason why pg_dump wouldn't
quote each array?

I've been searching online and haven't come across anything at all
related to this. I've never used arrays in Postgres before and this
particular instance will be a one-off.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2008-03-28 00:19:48 Re: dunction issue
Previous Message Greg Smith 2008-03-27 22:49:50 Re: Survey: renaming/removing script binaries (createdb, createuser...)