Thread: assigning values to array elements

assigning values to array elements

From
J Greenbaum
Date:
Hello,

I'm fairly new to postgres and I'm trying to write a PL/pgsql function and
keep getting an error message.  Here is the line that is giving me
trouble:

norm[i] := (NEW.area[i]/(A_slope * (i+18) + A_int)+NEW.area[i]/(C_slope *
(i+18) + C_int))/2;

The error message that I receive is: WARNING:  plpgsql: ERROR during
compile of norm_n_scan near line 27 ERROR:  parse error at or near "["

As you can see, I'm trying to assign a value to an array element, but it
isn't working for some reason.  FYI, "norm" is declared as a floating
point array of unlimited size.  Please let me know if you have any
suggestions.  Thanks!!

-Jay Greenbaum

P.S. My apologies for posting this to 2 lists!



Re: assigning values to array elements

From
Tom Lane
Date:
J Greenbaum <jj@bu.edu> writes:
> As you can see, I'm trying to assign a value to an array element, but it
> isn't working for some reason.

plpgsql doesn't support that yet :-(.

This needs to be fixed.  I'm not sure why it doesn't have an entry in
TODO.  Bruce, would you add something like* allow assignment to array elements
to the plpgsql section?
        regards, tom lane


Re: assigning values to array elements

From
J Greenbaum
Date:
Darn...guess I gotta do it in perl then.  Thx for your help.

On Mon, 13 Jan 2003, Tom Lane wrote:

> J Greenbaum <jj@bu.edu> writes:
> > As you can see, I'm trying to assign a value to an array element, but it
> > isn't working for some reason.
> 
> plpgsql doesn't support that yet :-(.
> 
> This needs to be fixed.  I'm not sure why it doesn't have an entry in
> TODO.  Bruce, would you add something like
>     * allow assignment to array elements
> to the plpgsql section?
> 
>             regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 



Re: assigning values to array elements

From
Bruce Momjian
Date:
Tom Lane wrote:
> J Greenbaum <jj@bu.edu> writes:
> > As you can see, I'm trying to assign a value to an array element, but it
> > isn't working for some reason.
> 
> plpgsql doesn't support that yet :-(.
> 
> This needs to be fixed.  I'm not sure why it doesn't have an entry in
> TODO.  Bruce, would you add something like
>     * allow assignment to array elements
> to the plpgsql section?

Added to TODO:
       o Allow PL/PgSQL to support array element assignment

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073