Re: Multidimensional array definition in composite type appears parsed as string

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: miller_2555 <nabble(dot)30(dot)miller_2555(at)spamgourmet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Multidimensional array definition in composite type appears parsed as string
Date: 2009-05-28 14:45:06
Message-ID: 8334.1243521906@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

miller_2555 <nabble(dot)30(dot)miller_2555(at)spamgourmet(dot)com> writes:
> I appreciate the clarification on the output. Given the assignment appears
> correct, what is the appropriate method to access the elements of the
> multidimensional array?

I think what you're missing is the distinction between slice and simple
element access, ie instead of this

(myvar[i]).multidimarray[j]

you'd need something like this

(myvar[i]).multidimarray[j][1:3]

The proposed loop coding is uselessly overcomplicated because it
supposes that 2-D arrays could be nonrectangular. Just use array_lower
and array_upper on dimension 2 of the 2-D array in the innermost loop.

You might want to practice a bit with a plain 2-D array field before
getting into the complexity of embedding it in a composite embedded
in an array ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Atul Chojar 2009-05-28 14:50:20 How to pass parameters into a sql script ?
Previous Message Scott Marlowe 2009-05-28 14:41:23 Re: What is the right way to deal with a table with rows that are not in a random order?