Re: Accessing array datatype

From: "Oliveiros Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "maria s" <psmg01(at)gmail(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Accessing array datatype
Date: 2008-07-28 17:21:14
Message-ID: 021201c8f0d6$568bcfd0$ec5a3d0a@marktestcr.marktest.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Maria,

Could you explain a little more the background?
What kind of output do you actually want?
.Do you need to retrieve all the arrays in that column in just one query?
Or just need to get one with a particular ID?

I learned bout the existence of arrays a few days ago :-)
If I had this problem and with my current knowledge on arrays I would issue first one query to obtain the dimension and then programmatically I would build the next query with the exact number of columns (I use C# for client programs).
It would work fine if you are just hunting for a particular record on your table, but I don't know if that's your goal....

Also, Please don't send private replies, always include the mailing list address
because someone with more knowledge than me might be able to quickly help you ;-)

Best,
Oliveiros

----- Original Message -----
From: maria s
To: Oliveiros Cristina
Sent: Monday, July 28, 2008 6:03 PM
Subject: Re: [SQL] Accessing array datatype

Hi Oliveiros,
Thank you so much for your reply.
I would like to get the elements of an array as columns instead of getting them as {a,b,..}

May be if I know the array boundary, then I can fetch the elements as I wish.

But I don't know is there any other way to get the data.

Thank you for your reply.

Maria

On Mon, Jul 28, 2008 at 12:56 PM, Oliveiros Cristina <oliveiros(dot)cristina(at)marktest(dot)pt> wrote:

Maria,

You mean your array has a variable size, which you need to know in order to properly construct a query?

Dunno much about arrays, but here http://www.postgresql.org/docs/8.3/static/arrays.html is said that array_upper( your_array, 1 ) returns the upper bound of the array...

Can this be what you need...?

Best,
Oliveiros
----- Original Message -----
From: maria s
To: Osvaldo Rosario Kussama ; pgsql-sql(at)postgresql(dot)org ; Pavel Stehule ; Ivan Sergio Borgonovo
Sent: Monday, July 28, 2008 5:09 PM
Subject: [SQL] Accessing array datatype

Hi All,
I have an array column in a table.
How can I fetch the elements separately( ie, select arr[1],arr[2]...arr[n]) as a column,
when I don't know how many elements are there in the array?

Thanks for your help.

Maria

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message maria s 2008-07-28 17:28:01 Re: Accessing array datatype
Previous Message Oliveiros Cristina 2008-07-28 16:56:11 Re: Accessing array datatype