Re: Stalled post to pgsql-general

Started by Sambaover 15 years ago2 messagesgeneral
Jump to latest
#1Samba
saasira@gmail.com

REPOST!

On Wed, Dec 1, 2010 at 8:34 PM, <pgsql-general-owner@postgresql.org> wrote:

Show quoted text

Your message to pgsql-general has been delayed, and requires the approval
of the moderators, for the following reason(s):

The author (Samba <saasira@gmail.com>)
is not a member of any of the restrict_post groups.

If you do not wish the message to be posted, or have other concerns,
please send a message to the list owners at the following address:
pgsql-general-owner@postgresql.org

---------- Forwarded message ----------
From: Samba <saasira@gmail.com>
To: pgsql-general@postgresql.org
Date: Wed, 1 Dec 2010 20:33:09 +0530
Subject: plpgsql : looping over multidimensional array : getting NULL for
subdimension
Hi all,

I'm trying to loop over a multidimensional array and find if any of
the elements in a sub-dimensional array are matching some known criteria but
facing issue with NULL for the sub arrays.

I have a data structure that looks like:

*some_array VARCHAR[][] :=
'{{samba,sarath,sreenivas},{samba,mukhesh,pavan}}'*;

I'm trying to assign the individual sub arrays to other array elements
like:

other-array VARCHAR[];

other_array=some_array[1];

and I'm expecting to get '{samba,sarath,sreenivas}' for index 1 and *{samba,mukhesh,pavan}
*for index 2;*
*however, I'm getting NULL.

Can some one explain the way I can assign subarrays to other array elements
plpgsql?

Thanks and Regards,
Samba

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Samba (#1)

Samba <saasira@gmail.com> writes:

REPOST!

Please fix the subject line to be something useful when you resend a
message.

I'm trying to assign the individual sub arrays to other array elements
like:

other-array VARCHAR[];

other_array=some_array[1];

and I'm expecting to get '{samba,sarath,sreenivas}' for index 1 and *{samba,mukhesh,pavan}
*for index 2;*
*however, I'm getting NULL.

You need to use array slice syntax if you want to extract a sub-array
rather than a single element. Try something like some_array[1:1]. See
http://www.postgresql.org/docs/9.0/static/arrays.html#ARRAYS-ACCESSING

regards, tom lane