Setting variables equal to elements from an Array - Mailing list pgsql-general

From cdecarlo
Subject Setting variables equal to elements from an Array
Date
Msg-id 0cd65a60-500c-4a74-a78a-4b3ac816b0b8@m77g2000hsc.googlegroups.com
Whole thread Raw
Responses Re: Setting variables equal to elements from an Array  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hello,

I'm new to pl/pgsql and postgres and I need some help with a part of
my function.  In the function I loop through a multidemensional array
( [n][3] ), once, while inside the loop, I find the index I want to
work with I would like to set a separate variable equal to the element
in the array at that index ( newVar = array[i] ).

I tried to accomplish this with the following bit of code:

newVar := mnArray[i]

but for some reason that assigned NULL to newVar, then I tried:

newVar := mnArray[i][3:3]

and that appeared to have worked, however when I try to index an
element in the newVar array it produces NULL.  I'm wondering two
things, first, does mnArray[i][3:3] return an array or a string
representation of the element at that index (which in this case is an
array)? and secondly, how do I do what I want to do (make newVar an
array)?

Thanks,

Colin

pgsql-general by date:

Previous
From: rihad
Date:
Subject: Re: need to dump/restore data for 8.3beta2 -> 8.3RC1 upgrade?
Next
From: Lew
Date:
Subject: Re: Need efficient way to do comparison with NULL as an option